Skip to content

fix(grid): ensure resize observer is only created if available in ssr - #17498

Merged
ChronosSF merged 2 commits into
masterfrom
mdragnev/fix-17497
Aug 14, 2026
Merged

fix(grid): ensure resize observer is only created if available in ssr#17498
ChronosSF merged 2 commits into
masterfrom
mdragnev/fix-17497

Conversation

@mddragnev

Copy link
Copy Markdown
Member

Closes #17497

Description

Adding a guard that enables creating a resize observer only in browser mode.

Motivation / Context

Type of Change (check all that apply):

  • Bug fix
  • New functionality
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactoring (no functional changes)
  • Documentation
  • Demos
  • CI/CD
  • Tests
  • Changelog
  • Skills/Agents

Component(s) / Area(s) Affected:

How Has This Been Tested?

  • Unit tests
  • Manual testing
  • Automated e2e tests

Test Configuration:

  • Angular version:
  • Browser(s):
  • OS:

Screenshots / Recordings

Checklist:

  • All relevant tags have been applied to this PR
  • This PR includes unit tests covering all the new code (test guidelines)
  • This PR includes API docs for newly added methods/properties (api docs guidelines)
  • This PR includes feature/README.MD updates for the feature docs
  • This PR includes general feature table updates in the root README.MD
  • This PR includes CHANGELOG.MD updates for newly added functionality
  • This PR contains breaking changes
  • This PR includes ng update migrations for the breaking changes (migrations guidelines)
  • This PR includes behavioral changes and the feature specification has been updated with them
  • Accessibility (ARIA, keyboard navigation, focus management) has been verified

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an SSR-safe guard around ResizeObserver creation in the grid virtualization IgxGridForOfDirective to prevent server-side build/runtime errors when window/ResizeObserver are unavailable.

Changes:

  • Avoid unconditional ResizeObserver instantiation by checking getResizeObserver() before creating viewObserver.
  • Ensure SSR environments can initialize the directive without throwing due to missing browser APIs.
Suppressed comments (1)

projects/igniteui-angular/directives/src/directives/for-of/for_of.directive.ts:1683

  • This SSR guard changes runtime behavior when ResizeObserver is missing (e.g., server build or non-DOM environment). Since this directive has an existing Jasmine spec suite, add a unit test that simulates window.ResizeObserver being unavailable and asserts that initialization does not throw.
        const resizeObserver = getResizeObserver();
        if (resizeObserver) {
            this.viewObserver = new resizeObserver((entries: ResizeObserverEntry[]) => this.viewResizeNotify.next(entries));
        }

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@viktorkombov viktorkombov self-assigned this Aug 12, 2026
@viktorkombov viktorkombov added 💥 status: in-test PRs currently being tested ✅ status: verified Applies to PRs that have passed manual verification and removed 💥 status: in-test PRs currently being tested labels Aug 12, 2026
@ChronosSF
ChronosSF merged commit e5b01c3 into master Aug 14, 2026
6 checks passed
@ChronosSF
ChronosSF deleted the mdragnev/fix-17497 branch August 14, 2026 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

angular: ssr grid version: 22.1.x ✅ status: verified Applies to PRs that have passed manual verification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SSR] Angular app with SSR enabled and grid throws a server error when built

5 participants