Skip to content

fix(framework): await pending language change in connectedCallback (2.23)#13801

Merged
ilhan007 merged 1 commit into
release-2.23.3from
fix/language-aware-onEnterDOM-2.23
Jul 8, 2026
Merged

fix(framework): await pending language change in connectedCallback (2.23)#13801
ilhan007 merged 1 commit into
release-2.23.3from
fix/language-aware-onEnterDOM-2.23

Conversation

@ilhan007

@ilhan007 ilhan007 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Backport of #13798 to the 2.23.x line, targeting the release-2.23.3 collector branch.

Following the same convention as #13733 (fix/shellbar-13729-2.23release-2.23.1).

Why

PR #13602 shipped in 2.23.0 and introduced a bug where language-aware components mounted while setLanguage() was in flight silently skipped `onEnterDOM`, breaking any consumer that registers listeners there (e.g. UDEX Footer's `ResizeHandler.register` — reported this week).

Change

Full rationale, design, and test coverage: see #13798.

Verified locally

Related

…st render

PR #13602 made connectedCallback bail out early for language-aware components
mounted while a language change was in progress. That path silently skipped
onEnterDOM, _fullyConnected, and _domRefReadyPromise resolution — so consumers
that register listeners or observers in onEnterDOM (e.g. the Udex Footer's
ResizeHandler.register call) never saw those side effects wired up.

Replace the boolean pending flag with a promise handle so connectedCallback can
await it directly and then continue on the normal render path. This keeps the
lifecycle invariant intact (onEnterDOM fires exactly once, after the first
render) and removes the need for any deferred-lifecycle bookkeeping.

Language.ts:
- languageChangePending changes from boolean to Promise<void> | null.
- A single startLanguageChange helper builds the promise, runs the deferred
  reRenderAllUI5Elements, and clears the field when done (only if a newer
  change hasn't replaced it).
- setLanguage() and the cross-runtime attachConfigChange handler share the
  helper, so both paths keep the field consistent.
- getLanguageChangePending() now returns the in-flight promise or null.

UI5Element.ts:
- connectedCallback awaits the pending promise for language-aware components,
  then proceeds normally. If the deferred re-render already rendered the
  element during the await, skip the redundant renderImmediately.
- _invalidate keeps its existing guard - a non-null promise is truthy, so the
  boolean check still works semantically.

Tests:
- New LanguageAwareLifecycle test element (languageAware: true, counts hook
  calls).
- New base/cypress/specs/LanguageAwareLifecycle.cy.tsx covering:
  * onEnterDOM fires exactly once after a pending language change resolves
  * onEnterDOM does not fire a second time on a subsequent re-render
  * onEnterDOM does not fire if the element is removed before rendering

Verified locally:
- 3/3 pass with the fix, 2/3 fail without it.
- Existing DatePicker_cldr_race and i18n_texts specs still pass.
@ilhan007 ilhan007 merged commit 4535b24 into release-2.23.3 Jul 8, 2026
23 of 27 checks passed
@ilhan007 ilhan007 deleted the fix/language-aware-onEnterDOM-2.23 branch July 8, 2026 13:29
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