Repository navigation
fix(Culture): apply culture setters to formats already used - #1343
Closed
jelic-nikola wants to merge 1 commit into
Closed
jelic-nikola wants to merge 1 commit into
jelic-nikola wants to merge 1 commit into
Conversation
Culture.invalidateCache() now also resets the default culture's cache, so setDefaultTimezone, setNumberCulture, setDateTimeCulture and setDefaultCurrency take effect on formats that were already used when culture-sensitive formatting is enabled (#1342).
Member
|
Thanks for the thorough analysis. Closing in favor of #1344, which takes the same idea (reset the default culture's cache when a setting changes) but does it in the setters through a shared helper instead of in |
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 #1342.
Problem
With culture-sensitive formatting enabled,
Culture.setDefaultTimezone,setNumberCulture,setDateTimeCultureandsetDefaultCurrencyhad no effect on formats that had already been used. Those formats kept the settings from their first use. OnlysetCultureworked.Importing
NumberFieldorMonthPickerenables culture-sensitive formatting, so apps that use these widgets are affected.Cause
In culture-sensitive mode, built formatters and compiled expressions and templates are cached on the default culture's
cacheobject, together with theNumberCultureandDateTimeCulturethey were built from. The setters calledinvalidateCache(), which bumps the global cache identifier and clears the global expression and template caches, but not the culture's own cache.setNumberCultureandsetDateTimeCulturealso dropped their culture object, but the formatters built from it stayed cached.setCultureworked because it replaces the whole cache.Fix
Culture.invalidateCache()now also resets the default culture's cache, the same resetsetCulturealready did. Every setter callsinvalidateCache(), so this fixes all of them with one change. The per-setterdeletelines and the separate reset insetCulturewere redundant and are removed.The issue suggested deleting the cached items in each setter instead, which has the same effect but needs a change in each setter.
Impact
setDefaultDateEncodingnow also resets the cache.createCulturekeep their own cache. The setters didn't affect them before and still don't.Not changed
tplorexprprops of widgets that already exist, because those are compiled when the widget is created. This was already the case forsetCulture.Testing
Culture.spec.tswith two tests, both failing without the fix: the timezone case from the issue (12:00 → 21:00), and a check that all four setters drop the cached formatters. The spec doesn't callenableCultureSensitiveFormatting(), because it can't be switched off and breaksutil/Format.spec.tsandexprHelpers.spec.tsin the same run.litmus/bugs/CultureSettersAfterFirstUse.js, loaded fromlitmus/index.js. Flip the switch: the four fields change (12:00 → 21:00, 04/24/2026 → 24.04.2026, 1,234.56 → 1.234,56, $1,234.56 → 1.234,56 €) and change back when it's flipped off. Before the fix they kept their first values.