-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(overlay): always dispatch keyboard events to top overlay in OverlayKeyboardDispatcher #10807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(overlay): always dispatch keyboard events to top overlay in OverlayKeyboardDispatcher #10807
Conversation
61841ad
to
d7b71fa
Compare
@@ -85,8 +73,8 @@ export class OverlayKeyboardDispatcher implements OnDestroy { | |||
/** Keyboard event listener that will be attached to the body. */ | |||
private _keydownListener = (event: KeyboardEvent) => { | |||
if (this._attachedOverlays.length) { | |||
// Dispatch keydown event to the correct overlay. | |||
this._selectOverlayFromEvent(event)._keydownEvents.next(event); | |||
// Dispatch the keydown event to the top overlay. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expand this with the rationale for why we always use the most recently opened overlay?
@@ -86,28 +86,6 @@ describe('OverlayKeyboardDispatcher', () => { | |||
button.parentNode!.removeChild(button); | |||
}); | |||
|
|||
it('should dispatch targeted keyboard events to the overlay containing that target', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be a test case with multiple open overlays?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's one called should dispatch body keyboard events to the most recently attached overlay
a bit above.
d7b71fa
to
5a14063
Compare
Addressed the feedback @jelbourn. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Can you see whats up with CircleCI breakage? |
…ayKeyboardDispatcher Currently when dispatching events through the `OverlayKeyboardDispatcher` we try to match one of the overlays to the element that triggered the event. This is problematic, because some components will open an overlay, but will keep focus on the trigger element (e.g. `mat-autocomplete` and `mat-select`). These changes switch the logic so the keyboard events are always dispatched to the top-level overlay. Fixes angular#10799.
5a14063
to
2ec751b
Compare
Looks like it was a flake @andrewseguin. It went away after a rebase. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Currently when dispatching events through the
OverlayKeyboardDispatcher
we try to match one of the overlays to the element that triggered the event. This is problematic, because some components will open an overlay, but will keep focus on the trigger element (e.g.mat-autocomplete
andmat-select
). These changes switch the logic so the keyboard events are always dispatched to the top-level overlay.Fixes #10799.