fix(element): don't render previous locale's text with the new font (#3043)#8927
Merged
Conversation
Build size reportThis PR changes the size of the minified bundles.
|
…3043) On a locale change the localized font and the localized text are updated by two separate handlers. When the new font is already cached its load fires synchronously, before the text handler runs, so the new font is briefly rendered with the previous locale's string - emitting spurious "character is missing" warnings. Refresh the localized text in _onFontLoad before applying the font so the two never mismatch. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ab57d96 to
f0da44c
Compare
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 #3043
Problem
On a locale change a localized Text Element updates its font and its text from two separate
i18nchange handlers. The font handler (LocalizedAsset, bound in the constructor) runs before the text handler (TextElement._onLocaleSet, bound inonEnable). When the new locale's font is already cached, itsloadfires synchronously and the new font is rendered with the previous locale's string before the text is updated — emitting spuriousCharacter 'X' is missingwarnings for the old language. When the font isn't cached the swap is async, so the bug only shows intermittently.Fix
Refresh the localized text in
_onFontLoadbefore applying the font, so the new font is never rendered with the previous locale's string. No-op for non-localized elements and for the async path.Testing
text-element.test.mjs) that fails without the fix and passes with it; full suite green.🤖 Generated with Claude Code