From c194661fa382635ea6a8693ddc424c85349f505c Mon Sep 17 00:00:00 2001 From: Laurent Dinclaux Date: Wed, 6 May 2026 20:11:10 +1100 Subject: [PATCH] fix: prevent username flash on load and remove select max-width --- ident_switch-switch.js | 2 -- ident_switch.css | 26 ++++++++++++++++++++++++++ ident_switch.php | 5 +---- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/ident_switch-switch.js b/ident_switch-switch.js index c80f42f..88028a8 100644 --- a/ident_switch-switch.js +++ b/ident_switch-switch.js @@ -67,7 +67,6 @@ function plugin_switchIdent_addCbLarry($wrapper, $sw) { $sw.css({ 'font-weight': 'bold', - 'max-width': '200px', 'text-overflow': 'ellipsis' }); @@ -104,7 +103,6 @@ function plugin_switchIdent_addCbElastic($wrapper, $sw) { 'font-weight': 'bold', 'color': 'inherit', 'box-shadow': 'none', - 'max-width': '200px', 'text-overflow': 'ellipsis', 'padding': '0 1.2em 0 0.25em' }); diff --git a/ident_switch.css b/ident_switch.css index 4f0f7f2..9628852 100644 --- a/ident_switch.css +++ b/ident_switch.css @@ -27,6 +27,32 @@ background-size: 10px 6px; } +/* + * Prevent flash of original username before JS prepends the switcher. + * The JS hides these elements at DOMReady, but the CSS rules below hide them + * earlier (during initial render) — only loaded when the switcher will actually + * be shown, so users without secondary accounts keep the default username display. + */ + +/* Elastic skin: switcher is prepended inside .header-title.username. + Hide the original username via visibility on the parent (affects the text + node), then re-show the wrapper. Unlike color/font-size, this preserves the + parent's flex/line-height context, keeping the wrapper vertically centered. */ +.header-title.username { + visibility: hidden; +} +.header-title.username > *:not(.ident-switch-wrapper) { + display: none; +} +.header-title.username > .ident-switch-wrapper { + visibility: visible; +} + +/* Larry skin: switcher is prepended next to .username inside #topline .topright */ +#topline .topright > .username { + display: none; +} + /* Unread badge */ .ident-switch-badge { flex-shrink: 0; diff --git a/ident_switch.php b/ident_switch.php index a39b8e7..e444876 100644 --- a/ident_switch.php +++ b/ident_switch.php @@ -158,10 +158,6 @@ class ident_switch extends rcube_plugin default => null, }; - if ($rc->task === 'mail') { - $this->include_stylesheet('ident_switch.css'); - } - return $args; } @@ -218,6 +214,7 @@ class ident_switch extends rcube_plugin return; } + $this->include_stylesheet('ident_switch.css'); $this->include_script('ident_switch-switch.js'); // Pass config to JS environment