Skip to content

fix(sidenav): restore focus if drawer is closed through backdrop click #19534

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

Merged

Conversation

devversion
Copy link
Member

Currently we do not restore focus properly when a drawer is closed
through backdrop click. This is because we only restore focus when
an element inside the drawer is focused before closing. This is not
the case when the backdrop is clicked, as the focus is usually
redirected to the document.body element.

Fixes #17749.

@devversion devversion added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent Accessibility This issue is related to accessibility (a11y) target: patch This PR is targeted for the next patch release labels Jun 4, 2020
@devversion devversion requested a review from mmalerba as a code owner June 4, 2020 10:49
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jun 4, 2020
@devversion devversion force-pushed the fix/drawer-restore-focus-backdrop-click branch 3 times, most recently from 47c1ca9 to 956f80f Compare June 4, 2020 13:40
Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@crisbeto crisbeto added the lgtm label Jun 4, 2020
Currently we do not restore focus properly when a drawer is closed
through backdrop click. This is because we only restore focus when
an element inside the drawer is focused before closing. This is not
the case when the backdrop is clicked, as the focus is usually
redirected to the `document.body` element.

Fixes angular#17749.
@devversion devversion force-pushed the fix/drawer-restore-focus-backdrop-click branch from 956f80f to 70474dc Compare June 4, 2020 14:27
Copy link
Contributor

@mmalerba mmalerba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

} else {
this._elementRef.nativeElement.blur();
}
// Note that we don't check via `instanceof HTMLElement` so that we can cover SVGs as well.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this is definitely easier to understand with the helper broken out

@mmalerba mmalerba added the action: merge The PR is ready for merge by the caretaker label Jun 4, 2020
@jelbourn jelbourn merged commit 5ed1a00 into angular:master Jun 29, 2020
jelbourn pushed a commit that referenced this pull request Jun 29, 2020
#19534)

Currently we do not restore focus properly when a drawer is closed
through backdrop click. This is because we only restore focus when
an element inside the drawer is focused before closing. This is not
the case when the backdrop is clicked, as the focus is usually
redirected to the `document.body` element.

Fixes #17749.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jul 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Accessibility This issue is related to accessibility (a11y) action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sidenav toggle button doesn't clear the button focus state
5 participants