Skip to content

fix(grid): read scroll and filter input from their elements - 21.2.x - #18099

Open
rkaraivanov wants to merge 1 commit into
21.2.xfrom
rkaraivanov/fix-grid-shadow-root-21.2.x
Open

rkaraivanov wants to merge 1 commit into
21.2.xfrom
rkaraivanov/fix-grid-shadow-root-21.2.x

Conversation

@rkaraivanov

Copy link
Copy Markdown
Member

Refs #17860

Description

  • IgxForOfDirective.onScroll / onHScroll and IgxGridForOfDirective.onScroll read the scroll position from their scroll element instead of event.target.
  • IgxGridFilteringRowComponent reads its input element instead of event.target when the debounced input is handled. The check for date-time columns, which use the emitted Date, now runs before the input is read.

Motivation / Context

This is the port of the #17860 part of # to 21.2.x. Part of #18088.

The vertical scroll handler runs after a throttle and the filter row handler after a debounce. By then the browser has set event.target to null for an event in a shadow tree, so in a grid that renders more than 100 cells each scroll threw Cannot read properties of null (reading 'scrollTop'), and the filter row did not filter.

#17859 does not apply to this branch: it has no IgxStylesRegistrar, and its theme still carries the structural styles of the grid. The changelog entry is under 21.2.28.

Type of Change (check all that apply):

  • Bug fix
  • Tests
  • Changelog

Component(s) / Area(s) Affected:

Grid, Tree Grid, Hierarchical Grid, Pivot Grid, igxFor

How Has This Been Tested?

  • Unit tests

Karma, with grid.component.spec.ts, grid-filtering-ui.spec.ts, the igxFor specs and the pivot grid specs:

Spec Without the fix With the fix
filtering UI › in a shadow root › should filter by the value typed in the filter row fail pass
grid › in a shadow root › should scroll to the last position of a throttled scroll fail pass
grid › scroll throttle trailing edge (2 specs, now stub scrollTop on the scroll element) fail pass

The new specs use an IgxGridInShadowRootComponent in grid-samples.spec.ts. It renders the grid inside @if in a ShadowDom component and copies the stylesheets of the page into its shadow root.

The run has 15 other failures, mostly row counts in the pivot grid specs. The same 15 fail on 21.2.x without this change in the same environment, where Karma used the system Chrome (PUPPETEER_EXECUTABLE_PATH=/usr/bin/google-chrome) instead of the pinned Puppeteer Chrome.

Lint of the changed files: 0 errors.

Test Configuration:

  • Angular version: 21.2.9
  • Browser(s): Chrome 158 (headless, Karma)
  • OS: Linux (WSL2)

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 CHANGELOG.MD updates for newly added functionality

🤖 Generated with Claude Code

The vertical scroll handler runs after a throttle and the filter row
input handler after a debounce. In a shadow root the browser clears the
event target when the dispatch ends, so reading event.target threw and
the rows did not follow the scrollbar or the filter was not applied.
The for-of directives read the scroll element and the filter row reads
its input element instead.

Port of the #17860 fix to 21.2.x.
Part of #18088

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rkaraivanov
rkaraivanov requested a review from mddragnev December 4, 2026 11:46
Copilot AI balanced review requested due to automatic review settings December 4, 2026 11:46

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.

🟡 Changes recommended

A pending debounced input event can throw after switching to a Date or Time column because the filtering input no longer exists.

1 open issue
What changed in this PR

Ports the shadow-root scrolling and filter-row fixes from #17860 to 21.2.x, addressing part of #18088.

Changes:

  • Read scroll positions and filter values directly from their elements.
  • Add shadow-root regression tests and update scroll-throttle tests.
  • Document the fixes under 21.2.28.
File Description
projects/​igniteui-angular/​test-utils/​grid-samples.spec.ts Adds a shared shadow-root grid fixture.
projects/​igniteui-angular/​grids/​grid/​src/​grid.component.spec.ts Tests shadow-root scrolling and updates throttle simulations.
projects/​igniteui-angular/​grids/​grid/​src/​grid-filtering-ui.spec.ts Tests debounced filtering inside a shadow root.
projects/​igniteui-angular/​grids/​core/​src/​filtering/​base/​grid-filtering-row.component.ts Reads filter values from the input element.
projects/​igniteui-angular/​directives/​src/​directives/​for-of/​for_of.directive.ts Reads scroll positions from scroll elements.
CHANGELOG.md Documents the shadow-root fixes.

Review effort: Balanced

// when you have a japanese character as a placeholder, on init the value here is empty string .
// Read the input, not the event target: the debounced call runs after the dispatch, when the browser
// has cleared the target of an event in a shadow tree.
const target = this.input.nativeElement;

This branch has not been deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants