Skip to content

fix(ui5-dynamic-page): guard against null scrollContainer in _toggleHeader#13255

Merged
ilhan007 merged 1 commit intomainfrom
fix/dynamic-page-toggle-header-null-check
Mar 11, 2026
Merged

fix(ui5-dynamic-page): guard against null scrollContainer in _toggleHeader#13255
ilhan007 merged 1 commit intomainfrom
fix/dynamic-page-toggle-header-null-check

Conversation

@ilhan007
Copy link
Contributor

Summary

  • Add null checks for scrollContainer in _toggleHeader, snapTitleByScroll, and onPinClick to prevent TypeError when the component is not yet fully initialized
  • Remove all scrollContainer! non-null assertions in favor of proper guards
  • When React renders <ui5-dynamic-page header-snapped> during initial mount, attributeChangedCallback fires before the shadow DOM is rendered, so scrollContainer (a @query result) is null

Fixes #13236

Test plan

  • All 30 existing DynamicPage Cypress tests pass
  • Verify in a React app that rendering <ui5-dynamic-page header-snapped> no longer throws

…eader

When React renders DynamicPage with header-snapped attribute during
initial mount, _toggleHeader can be called before the component's
shadow DOM is rendered, causing scrollContainer to be null.

Add null checks for scrollContainer in _toggleHeader, snapTitleByScroll,
and onPinClick to prevent TypeError when the component is not yet
fully initialized.

Fixes #13236
@ui5-webcomponents-bot
Copy link
Collaborator

ui5-webcomponents-bot commented Mar 11, 2026

🧹 Preview deployment cleaned up: https://pr-13255--ui5-webcomponents.netlify.app

@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview March 11, 2026 14:13 Inactive
@ilhan007 ilhan007 requested a review from kgogov March 11, 2026 14:27
@ilhan007 ilhan007 merged commit 14873e8 into main Mar 11, 2026
27 of 30 checks passed
@ilhan007 ilhan007 deleted the fix/dynamic-page-toggle-header-null-check branch March 11, 2026 14:38
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview March 11, 2026 14:38 Inactive
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.

[DynamicPage]: Error in _toggleHeader TypeError: Cannot read properties of null (reading 'scrollTop')

3 participants