fix(ui5-date-picker): prevent errors when CLDR data is not loaded#12807
fix(ui5-date-picker): prevent errors when CLDR data is not loaded#12807hinzzx wants to merge 1 commit into
Conversation
|
🚀 Deployed on https://pr-12807--ui5-webcomponents-preview.netlify.app |
GDamyanov
left a comment
There was a problem hiding this comment.
Overall these changes will prevent the errors in the console. However we should try to find a general solution regarding the issue with the CLDR. Also I think that will be good to add some logging in the PR when CLDR data is not loaded and try to use it.
| if (!format) { | ||
| return false; | ||
| } | ||
| const date = format.parse(dateString); |
There was a problem hiding this comment.
I don't think that if there is no format will be good to return false
There was a problem hiding this comment.
That’s why we have a fallback. I think it's the safest approach.
The most efficient possible solution I discovered with the help of AI would bring breaking changes imo, so we should discuss those offline. |
The CLDR data is loaded asynchronously during component definition via dynamic imports
customElements.whenDefined()resolves when the element is registered, not when async data is loadedSo there is a race condition where methods like
isValidValue()could be called immediately aftercustomElements.whenDefined()resolves, before the asynchronous CLDR data fetch completes.DatePicker validation and formatting methods now return safe defaults when CLDR data is not yet loaded, instead of throwing errors.
Another possible solution would be to introduce a private event (something like 'cldr-load'), to re-render the component once the CLDR "becomes" available.