Skip to content

fix: use :scope instead of & in relative querySelector - #9

Merged
fastfrwrd merged 1 commit into
chore/sync-comcast-upstreamfrom
dataviz/querySelector-scope-selector
Aug 11, 2026
Merged

fix: use :scope instead of & in relative querySelector#9
fastfrwrd merged 1 commit into
chore/sync-comcast-upstreamfrom
dataviz/querySelector-scope-selector

Conversation

@fastfrwrd

Copy link
Copy Markdown

Summary

Targets the chore/sync-comcast-upstream branch (#7) so the published @grafana/react-data-grid build carries this fix.

getRowToScroll / getCellToScroll in src/utils/domUtils.ts prefix a relative querySelector with the CSS-nesting & combinator:

gridEl.querySelector('& > [role="row"] > [tabindex="0"]')

Chromium tolerates the leading &, but jsdom (nwsapi) — which grafana's Table unit tests run in — throws SyntaxError: '...' is not a valid selector, breaking header/cell focus on every header click. Without this, grafana's jest CI fails when it consumes this build (surfaced while validating the beta.59 bump in grafana-ui).

Change

Use :scope instead of & in both helpers. Equivalent in the browser, valid everywhere.

Also submitted upstream: Comcast#4131

🤖 Generated with Claude Code

getRowToScroll/getCellToScroll build a relative selector to find the focused
row/cell within the grid element. They prefix it with the CSS-nesting `&`
combinator. Chromium happens to accept `&` at the start of a querySelector
argument, but the standard token for "the element querySelector was called on"
is `:scope`. Environments whose selector engine follows the spec strictly — for
example jsdom (nwsapi), widely used in unit tests — throw
`SyntaxError: '& > [role="row"]...' is not a valid selector`, breaking header
and cell focus. Use `:scope`, which is equivalent in the browser and valid
everywhere.
@fastfrwrd
fastfrwrd requested a review from a team as a code owner August 11, 2026 16:46
@fastfrwrd
fastfrwrd requested review from briangann, drew08t and gelicia and removed request for a team August 11, 2026 16:46
@fastfrwrd
fastfrwrd merged commit 71f6299 into chore/sync-comcast-upstream Aug 11, 2026
10 checks passed
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