Skip to content

fix(material/select): stop event propagation on keyboard close in inl…#33210

Open
yannyannyann wants to merge 1 commit intoangular:mainfrom
yannyannyann:fix/mat-select-keyboard-focus-inline-popover
Open

fix(material/select): stop event propagation on keyboard close in inl…#33210
yannyannyann wants to merge 1 commit intoangular:mainfrom
yannyannyann:fix/mat-select-keyboard-focus-inline-popover

Conversation

@yannyannyann
Copy link
Copy Markdown

…ine popover mode

When mat-select uses inline popover positioning (the default), the CDK overlay host is inserted inside the mat-select host element. This caused keydown events (ENTER, SPACE, ALT+Arrow) handled by the open panel to bubble up to the host element's listener, which then ran _handleClosedKeydown and immediately re-opened the panel.

Fixed by calling event.stopPropagation() in _handleOpenKeydown for the ENTER/SPACE selection and ALT+Arrow close branches. Also added a focus() call before close() in the ALT+Arrow branch so focus is explicitly restored to the trigger before the overlay detaches, consistent with the Tab and ENTER paths.

This bug was particularly noticeable with screen readers since the panel would re-open immediately after selection, causing aria-expanded to toggle true→false→true in a single frame and confusing the a11y tree.

…ine popover mode

When mat-select uses inline popover positioning (the default), the CDK
overlay host is inserted inside the mat-select host element. This caused
keydown events (ENTER, SPACE, ALT+Arrow) handled by the open panel to
bubble up to the host element's listener, which then ran _handleClosedKeydown
and immediately re-opened the panel.

Fixed by calling event.stopPropagation() in _handleOpenKeydown for the
ENTER/SPACE selection and ALT+Arrow close branches. Also added a focus()
call before close() in the ALT+Arrow branch so focus is explicitly
restored to the trigger before the overlay detaches, consistent with
the Tab and ENTER paths.

This bug was particularly noticeable with screen readers since the panel
would re-open immediately after selection, causing aria-expanded to
toggle true→false→true in a single frame and confusing the a11y tree.
@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 6, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@crisbeto
Copy link
Copy Markdown
Member

crisbeto commented May 6, 2026

Do you have a repro for it? I don't see the select reopening on enter in our dev app here: https://ng-comp-devapp.web.app/select

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants