WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.47k stars 4.18k forks source link

Block pattern inserter modal: adding a pattern moves focus outside of the Modal #64853

Open ciampo opened 1 month ago

ciampo commented 1 month ago

What

When clicking on a pattern in the block patterns inserter modal, focus is moved outside of the modal itself.

https://github.com/user-attachments/assets/5bcacc13-7562-43e9-8d5e-dc7647e9255e

Not sure if this has always been a problem, or if it's a regression caused by other changes.

Proposed solution

Losing focus while the modal is open is considered an anti-pattern.

There are two alternative solutions:

ciampo commented 1 month ago

cc @ntsekouras and @scruffian who are among the last folks to have worked on this

ntsekouras commented 1 month ago

If I remember correctly when it was first implemented the inserter used to close and there was no focus loss issue. This seems related to the changes to keep the inserter open after an insertion. Maybe @MaggieCabrera can ping some folks to see if that's the case?