Skip to content

Botch of focus return when dismissing Modal by clicking outside #51722

@stokesman

Description

@stokesman

Description

When a modal is dismissed, focus is expected to return to the element that opened the modal. This fails when dismissing a modal by clicking outside it.

Step-by-step reproduction instructions

  1. Start in the Post Editor
  2. Open the Options menu
  3. Open the Preferences modal
  4. Click outside the Preferences modal to dismiss it
  5. Observe the Options menu is still open and clicking or focus other elements does not cause it to close.

Screenshots, screen recording, code snippet

Here are a couple instances of the issue but there are more uses of Modal that are probably affected.

Preferences modal

Google.Chrome.-.Edit.Post.My.WordPress.Website.WordPress.2023-06-20.at.8.46.52.PM.mp4

Post visibility confimation dialog

This is a ConfirmDialog which is built on top of Modal. I would expect the visibility dropdown menu would stay open and the focus return to the 'private' radio.

Google.Chrome.-.Edit.Post.My.WordPress.Website.WordPress.2023-06-20.at.8.40.39.PM.mp4

Environment info

  • Gutenberg trunk running on wp-now
  • Chrome
  • macOS

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Metadata

Metadata

Assignees

Labels

[Focus] Accessibility (a11y)Changes that impact accessibility and need corresponding review (e.g. markup changes).[Package] Components/packages/components[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions