Skip to content

fix: resolve CSS isolation conflicts in language selector when embedded in WordPress#452

Merged
YvesCesar merged 1 commit into
mainfrom
fix/language-selector-css-isolation
Jul 22, 2026
Merged

fix: resolve CSS isolation conflicts in language selector when embedded in WordPress#452
YvesCesar merged 1 commit into
mainfrom
fix/language-selector-css-isolation

Conversation

@vitormattos

@vitormattos vitormattos commented Jul 18, 2026

Copy link
Copy Markdown
Member

Problem

When the header fragment is loaded in WordPress/WooCommerce, several Bootstrap and theme CSS rules bleed into the language selector dropdown because the fragment CSS lacked explicit overrides. Multiple visual regressions were identified by comparing the static site (libresign.coop) against the WordPress-embedded fragment.

Root causes and fixes

1. Header height inflated 76 px → 92 px in WordPress

.ud-nav-dropdown-toggle in header-fragment.scss was not scoped to .nav-item, so min-height: 40px and padding: 8px 0 — intended for the main nav dropdowns (Solutions, Features) — also applied to the language selector button. This added 16 px to the header height.

Fix: scope .ud-nav-dropdown-toggle rules to .nav-item .ud-nav-dropdown-toggle (matching _header.scss), and use the padding shorthand on .selector .dropdown-toggle to explicitly zero out the vertical padding that Bootstrap button resets add.

2. Language codes (NB-NO, PT-BR) wrapping to two lines

Bootstrap's .dropdown-menu a adds horizontal padding, shrinking the usable space inside the dropdown below what those codes need at runtime.

Fix: add padding: 0 and white-space: nowrap to .selector .ud-submenu-link.

3. Language item text bold in WordPress

.ud-nav-submenu-link { font-weight: 600 } (meant for nav submenus) applies to the language links too because they share the class. The .selector .ud-submenu-link rule did not override it.

Fix: add font-weight: 400 to .selector .ud-submenu-link.

4. Dropdown too narrow — "Help translate ✏️" clipped on the right

width: 128px was a hard fixed value. The static site happened to reach 160 px only because Bootstrap's .dropdown-menu { min-width: 10rem } silently overrode it. The fragment's scoped rule had higher specificity and stayed at 128 px in WordPress, leaving only 96 px of content area — not enough for the CTA text (~114 px).

Fix: change width: 128pxmin-width: 160px in both files so the intent is explicit and the dropdown can grow for longer content.

5. Dropdown height mismatch between static site and WordPress

Bootstrap's .dropdown-menu was adding:

  • border: 1px solid — 2 px extra height
  • hr { margin: 1rem 0 } — separator 33 px vs 17 px in the fragment

Fix (in _header.scss): add border: none and hr { margin: 8px 0 } inside .selector .ud-submenu, making the static site match the fragment's intentional values (both 285 px).

6. Font-size mismatch in language items (16 px vs 15 px)

The fragment CSS sets font-size: 15px via .ud-nav-submenu-link, which applies in WordPress. The static site inherited 16 px from Bootstrap's body because .ud-nav-submenu-link { font-size: 15px } in _header.scss is nested under .nav-item .ud-nav-submenu and does not reach the language selector.

Fix (in _header.scss): add font-size: 15px to .selector .ud-submenu-link.

Note

Only reproducible at WordPress side.

Before After
image image

…ed in WordPress

When the header fragment is loaded in WordPress/WooCommerce, several
Bootstrap and theme CSS rules bleed into the language selector dropdown
because the fragment CSS lacked explicit overrides.

Issues fixed in header-fragment.scss:
- .ud-nav-dropdown-toggle was not scoped to .nav-item, so min-height:40px
  and padding:8px 0 (meant for nav dropdowns) also applied to the language
  selector button, inflating the header from 76px to 92px
- Same scope fix applied to the responsive rule
- .selector .dropdown-toggle: use padding shorthand (0 12px 0 0) to
  explicitly zero out top/bottom padding added by Bootstrap button resets
- .selector .ud-submenu: width:128px -> min-width:160px so the dropdown
  can grow to fit content instead of clipping at a fixed size
- .selector .ud-submenu-link: add padding:0 (neutralise Bootstrap
  .dropdown-menu a padding), white-space:nowrap (prevent NB-NO / PT-BR
  from wrapping), and font-weight:400 (override bold from
  .ud-nav-submenu-link which shares the same element)

Issues fixed in _header.scss to align static site with fragment:
- .selector .ud-submenu: width:128px -> min-width:160px (static site was
  reaching 160px only via Bootstrap .dropdown-menu min-width fallback;
  now the intent is explicit)
- .selector .ud-submenu: add border:none to prevent Bootstrap
  .dropdown-menu border from making the dropdown taller than WordPress
- .selector .ud-submenu: add hr { margin:8px 0 } to match the fragment
  CSS value; Bootstrap was applying margin:1rem adding 16px extra height
- .selector .ud-submenu-link: add font-size:15px; the static site
  inherited 16px from Bootstrap body while WordPress got 15px from the
  fragment's .ud-nav-submenu-link rule

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://libresign.github.io/site-preview/pr-preview/pr-452/

Built to branch main at 2026-07-18 14:15 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@vitormattos
vitormattos requested a review from YvesCesar July 18, 2026 14:17
@YvesCesar
YvesCesar merged commit 73a81bf into main Jul 22, 2026
5 checks passed
@YvesCesar
YvesCesar deleted the fix/language-selector-css-isolation branch July 22, 2026 18:44
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Starting production deploy of site header and footer fragments...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants