Skip to content

fix(aria/grid): activate composed widgets when child inputs receive focus - #34077

Merged
crisbeto merged 1 commit into
angular:mainfrom
nagahara-naoki:fix-aria-grid-widget-child-focus
Nov 10, 2026
Merged

crisbeto merged 1 commit into
angular:mainfrom
nagahara-naoki:fix-aria-grid-widget-child-focus

Conversation

@nagahara-naoki

Copy link
Copy Markdown
Contributor

Summary

Fixes #34076.

Focusing a child input inside a complex GridCellWidget composed through hostDirectives leaves the widget in cell mode. Add the static ngGridCellWidget host attribute so GridCell._getWidget() can find the containing widget and forward focus events. This follows the static marker approach used in #33839.

Add two tests comparing standard and composed widgets. Both verify that the input receives real DOM focus and the widget activates. The composed case fails before the fix.

StackBlitz reproduction: click each input and compare the displayed CELL/WIDGET mode. Detailed steps are in #34076.

This PR is independent of #34075 and addresses widget activation rather than cell selection.

Validation

  • Chromium grid suite passes with the fix (pnpm test src/aria/grid --no-watch).
  • pnpm bazelisk test //goldens:aria_api passes; no public API changes.
  • Targeted TSLint, pnpm ng-dev format changed --check, and git diff --check pass.
  • Confirmed the published-package bug with actual mouse clicks in Chrome using the StackBlitz reproduction (Angular 22.2.4, Aria 22.2.6).

Full repository suites and Firefox were not run locally.

…ocus

Apply the ngGridCellWidget host attribute so ancestor lookup forwards child focus events to composed widgets. Add standard and composed focus regression cases.

Fixes angular#34076
@Devyalamaddi

Copy link
Copy Markdown

Hey @nagahara-naoki, thanks for referencing #33839! Seeing how @crisbeto resolved the accordion trigger with 'ngAccordionTrigger': '' in host makes complete sense for keeping patterns consistent across the repo.

Just to summarize the trade-offs between both approaches for the maintainers:

  1. Static host attribute ('ngGridCellWidget': '' / 'ngGridCell': '') (Current PR):

  2. DOM containment (Node.contains()):

    • Pros: Completely decouples directive lookup from CSS attribute selectors, avoids closest() DOM traversals, and naturally resolves any arbitrary child markup.
    • Trade-off: Requires slightly refactoring _getWidget() / _getCell().

Both approaches effectively solve the bug when using hostDirectives. Happy to support whichever convention the team prefers!

@nagahara-naoki

Copy link
Copy Markdown
Contributor Author

@Devyalamaddi Thanks for summarizing the trade-offs! Happy to follow the team’s preferred approach.

@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Nov 10, 2026
@crisbeto
crisbeto merged commit 577dba7 into angular:main Nov 10, 2026
36 checks passed
@crisbeto

Copy link
Copy Markdown
Member

This PR was merged into the repository. The changes were merged into the following branches:

crisbeto pushed a commit that referenced this pull request Nov 10, 2026
…ocus (#34077)

Apply the ngGridCellWidget host attribute so ancestor lookup forwards child focus events to composed widgets. Add standard and composed focus regression cases.

Fixes #34076

(cherry picked from commit 577dba7)
@nagahara-naoki

Copy link
Copy Markdown
Contributor Author

Thanks for the reviews and for merging this into both main and 22.2.x!

@nagahara-naoki
nagahara-naoki deleted the fix-aria-grid-widget-child-focus branch November 10, 2026 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: aria/grid target: patch This PR is targeted for the next patch release

4 participants