Skip to content

fix: let a visitor choose a language when the page holds two switchers - #53

Open
TallblokeUK wants to merge 1 commit into
betafrom
fix/one-switcher-open
Open

TallblokeUK wants to merge 1 commit into
betafrom
fix/one-switcher-open

Conversation

@TallblokeUK

@TallblokeUK TallblokeUK commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes a support ticket on 1.0.3: the language switcher does nothing when added to a menu or as a shortcode in an Elementor header.

Cause

Every switcher on a page shared one open state, and each one closes the list on a mouse press outside itself. A menu item is printed twice (desktop menu plus the hidden mobile menu), and Elementor headers often hold a desktop and a mobile copy. Pressing on a language in the visible switcher counted as an outside press for the hidden copy, which closed the shared list before the click landed. The visitor sees the list close and the language stay the same. Pages with a single switcher were unaffected.

Change

src/apps/translatewp/index.tsx now remembers which switcher is open (the floating one or a particular placeholder). Each copy opens and closes only itself, so a hidden copy can no longer close the visible one, and opening one switcher no longer opens every copy on the page.

Checks

  • New test in switcherSurfaces.test.tsx: two placeholders, one hidden; opens the visible one, presses and clicks Español, expects /es/about/. On the old code it fails with the address left at /about/.
  • yarn lint:php, yarn lint:styles, yarn typecheck, yarn test (1479 passed), yarn build: all pass.
  • composer run test:php: 177 of 178 pass. The verify / build check fails on tests/QuotaHandoffTest.php, unrelated to this change (no PHP is touched). The test hard-codes a quota window ending 2026-11-01T00:00:00Z; that date has passed, so the handoff is no longer active and the test fails on every branch from 1 November. It also uses 2026-12-01 and 2026-12-02, which will expire next month. Moving those dates well into the future makes it pass again. main likely has the same test.
  • Tested locally with Hello Elementor 3.5.1 and Elementor: switcher in the header menu (desktop plus hidden mobile copy) and an Elementor Shortcode widget on the same page. Before: choosing a language did nothing. After: the menu switcher goes from /de/ to /es/, the shortcode switcher from /es/ to /de/, and clicking elsewhere still closes the list.

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.

1 participant