Closed anveshmekala closed 1 year ago
While localizing numbers for a specific numberingSystem, it is cached by the browser and used by other components in the same page. localized numbers using numberingSystem should be specific for a component and should not be applied to other components in the same page.
Small clarification in case someone grabs this before I do - we want the components to continue using the same NumberFormatter if they have matching lang/numberingSystem (I assume this is the case in 99% of apps).
Adding it to the render block just makes sure the component is always using a NumberFormatter for its lang/numberingSystem if the app has components with different i18n.
@anveshmekala numberFormatOptions
is already set in calcite-input-date-picker
's render block:
When you created the checklist above, did you go through and check all the components' code, or was it based on some behavior you saw? Let me know if there is more investigation needed on my end. Thanks!
i remember going through each component. I would recommend more investigation just to make sure no other components had implemented this since the creation of the epic.
Looked into this a bit more and numberStringFormatter.numberFormatOptions
only needs to be called in the render
block if a number is being formatted in the render
block via numberStringFormatter.localize()
.
Some components like calcite-input
store the localized number as State instead. This works because calcite-input
rerenders won't cause the value to be relocalized so there won't be a conflict, even if a different component changes the lang of the formatter cached by NumberStringFormat.
Instead, calcite-input
sets numberStringFormatter.numberFormatOptions
in event handlers and other places were the value can change before it localizes the number.
I can try to give a more detailed explanation if that was confusing.
It could also be worth moving the numberStringFormatter.localize()
calls out of the render blocks when possible to improve performance.
Installed and assigned for verification.
Created #7920 based on my comment above.
Actual Behavior
While localizing numbers for a specific
numberingSystem
, it is cached by the browser and used by other components in the same page.Expected Behavior
localized numbers using
numberingSystem
should be specific for a component and should not be applied to other components in the same page.Reproduction Sample
https://codepen.io/ANVESHMEKALA/pen/YzjaveB?editors=100
Reproduction Steps
1.Click on the stepper item with arabic numbers 2.Then, click on the stepper item above with latin numbers 3.Observe that latin numbers changes to arabic.
Reproduction Version
beta.97
Relevant Info
List of affected components:
Please feel free to add if any other components experience similar behavior.
Regression?
No response
Impact
No response
Esri team
N/A