Site Editor: Standardize initial focus of the Actions modal dialogs (no autofocus) #52601
Labels
[Focus] Accessibility (a11y)
Changes that impact accessibility and need corresponding review (e.g. markup changes).
[Package] Edit Site
/packages/edit-site
[Type] Bug
An existing feature does not function as intended
Description
In the Site Editor, various editable objects have an associated `Actions' button. Some of the availeble Actions open a modal dialog.
Initial focus on these dialogs is inconsistent: sometimes it is set to the modal dialog container itself, sometimes on an input field within the modal dialog. Examples:
Creating a new pattern: initial focus is on the modal dialog:
Renaming a menu: initial focus is on the modal dialog:
Creating a new page: initial focus is on the page title input field:
This is inconsistent. There should be no surprises for users, initial focus should behave consistently.
I can partly understand why initial focus is set to the Page title when creating a new page: That's the main required action. But then, it should work the same way when creating a Pattern: entering the patter nname is the main required action.
From an accessibility perspective, there are pros and cons in the two different behaviors:
I'm not sure managing initial focus on a case by case basis would be the best option. In my opinio, the best option would be to set initial focus on the modal dialog itself. Advantages:
More importantly, auto-focusing controls should be avoided. There are good reasons why the
jsx-a11y/no-autofocus
rule checks for that. In very limited cases auto-focusing may be useful but this is not one of them. In this case, disabling the eslint rule seems less than ideal: Cc @jeryj @ramonjdgutenberg/packages/edit-site/src/components/add-new-page/index.js
Line 76 in 032b261
See the conversation on the PR that introduced autoFocus in the create new page modal dialog.
There's a total of 8 occurrences of
jsx-a11y/no-autofocus
in the codebase:*native.js
files: I'd leave these cases to others who are interested in contributing to the React Native editor for mobile.autoFocus
attribute in other*native.js
files.Step-by-step reproduction instructions
autofocus
for the page title input field.Screenshots, screen recording, code snippet
No response
Environment info
No response
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
The text was updated successfully, but these errors were encountered: