Skip to content

fix(ui5-date-picker): guard languageAware renders against in-flight language changes#13840

Open
nnaydenow wants to merge 1 commit into
mainfrom
fix/cldr-locale-data-cache-poisoning
Open

fix(ui5-date-picker): guard languageAware renders against in-flight language changes#13840
nnaydenow wants to merge 1 commit into
mainfrom
fix/cldr-locale-data-cache-poisoning

Conversation

@nnaydenow

@nnaydenow nnaydenow commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Problem

When setLanguage() is called without await, CLDR data is fetched asynchronously. Components already queued for rendering (via renderDeferred) before the language change fires can still enter onBeforeRendering / onAfterRendering while localeDataMap is empty, causing:

TypeError: Cannot read properties of undefined (reading 'ca-gregorian')

_invalidate() already suppresses new invalidations during a language change for languageAware components, but components that were already sitting in the deferred render queue before setLanguage() was called could still reach _render() and execute their lifecycle hooks.

Fix

UI5Element._render() — skip the render entirely for languageAware components while getLanguageChangePending() is non-null. reRenderAllUI5Elements({ languageAware: true }) re-renders them once CLDR and i18n data are ready.

Test changes

  • Unskips the DatePicker Cypress test suite (was marked .skip due to this bug)
  • Updates setLanguage() calls in DatePicker and DateRangePicker Cypress specs to use explicit return inside .then() so Cypress correctly awaits the resolved promise before proceeding

@nnaydenow
nnaydenow temporarily deployed to netlify-preview July 17, 2026 14:18 — with GitHub Actions Inactive
@nnaydenow
nnaydenow force-pushed the fix/cldr-locale-data-cache-poisoning branch from 6ec8c94 to 882eaec Compare July 17, 2026 14:19
@nnaydenow
nnaydenow temporarily deployed to netlify-preview July 17, 2026 14:19 — with GitHub Actions Inactive
@nnaydenow nnaydenow changed the title fix(ui5-date-picker): clear LocaleData cache on language change to prevent stale CLDR data fix(ui5-date-picker): guard languageAware renders against in-flight language changes Jul 17, 2026
…anguage changes

When setLanguage() is called without await, CLDR data is fetched asynchronously.
Components already queued for rendering (via renderDeferred) before the language
change fires could still enter onBeforeRendering / onAfterRendering while
localeDataMap is empty, causing:

  TypeError: Cannot read properties of undefined (reading 'ca-gregorian')

Two changes:

1. UI5Element._render(): skip the render for languageAware components while
   getLanguageChangePending() is non-null. _invalidate() already suppresses new
   invalidations during this window, but components queued before the language
   change started could still reach _render(). This guard closes that gap —
   reRenderAllUI5Elements({ languageAware: true }) re-renders them once CLDR
   and i18n data are ready.

2. getCachedLocaleDataInstance: attach a language-change listener that clears
   the LocaleData cache. This ensures that after a language change, the next
   call creates a fresh LocaleData instance backed by the newly loaded CLDR
   data rather than reusing a stale one from the previous locale.

Also unskips the DatePicker Cypress test suite (marked skip due to this bug)
and updates setLanguage() calls in DatePicker and DateRangePicker Cypress specs
to use explicit return inside .then() so Cypress correctly awaits the promise.
@nnaydenow
nnaydenow force-pushed the fix/cldr-locale-data-cache-poisoning branch from 882eaec to c926998 Compare July 17, 2026 14:20
@nnaydenow
nnaydenow temporarily deployed to netlify-preview July 17, 2026 14:20 — with GitHub Actions Inactive
@sap-ui5-webcomponents-release

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant