TT-6225 fix: re-render UI when language changes a second time#363
Draft
nabalone wants to merge 1 commit into
Draft
TT-6225 fix: re-render UI when language changes a second time#363nabalone wants to merge 1 commit into
nabalone wants to merge 1 commit into
Conversation
The localized strings live as react-localization LocalizedStrings instances that are mutated in place by setLanguage, so their reference never changes on a language switch and useSelector skips the re-render, leaving stale labels until a page refresh. The localStrings selector now returns a fresh, prototype-preserving snapshot keyed on (source, language), giving consumers a new identity exactly when the displayed strings change while caching one snapshot per layout to keep references stable between renders. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
Fixes TT-6225: a second UI language change (e.g. French → English) didn't take effect until a manual page refresh (F5), and in some versions caused a React #301 crash on refresh.
The localized strings are stored in redux as react-localization
LocalizedStringsinstances. Switching language only flipsstate.strings.lang; the per-layout instances are mutated in place viasetLanguage, so their object reference never changes. As a resultuseSelector(which compares by reference / shallowEqual) saw "no change" and skipped the re-render, leaving stale labels on screen.The
localStringsselector now returns a fresh, prototype-preserving snapshot keyed on(source, language). The snapshot keeps theLocalizedStringsprototype (sogetString/formatStringstill work) but has a new identity, so consumers re-render exactly when the displayed strings change. One snapshot is cached per layout to keep references stable between renders for the same language, avoiding spurious re-renders for consumers that don't use shallowEqual.Test plan
🤖 Generated with Claude Code