Repository navigation
fix: let a visitor choose a language when the page holds two switchers - #53
Open
TallblokeUK wants to merge 1 commit into
Open
TallblokeUK wants to merge 1 commit into
TallblokeUK wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.tsxnow 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
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. Theverify / buildcheck fails ontests/QuotaHandoffTest.php, unrelated to this change (no PHP is touched). The test hard-codes a quota window ending2026-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 uses2026-12-01and2026-12-02, which will expire next month. Moving those dates well into the future makes it pass again.mainlikely has the same test./de/to/es/, the shortcode switcher from/es/to/de/, and clicking elsewhere still closes the list.