Opened 5 weeks ago
Closed 3 weeks ago
#65804 closed defect (bug) (fixed)
Image editor: initial focus incorrectly set to the crop area
| Reported by: | afercia | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.1 |
| Component: | Media | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: | accessibility |
Description
When a modal dialog opens, initial focus should be set to the most logical place:
- When there's only one, unique, task users can perform: set initial focus on the control related to that task. For example: the 'Rename block' modal dialog contains only one input field and only one action.
- Otherwise, when there are multiple flows and actions users may take, do not make any assumption and set initial focus on the modal dialog container.
In the new Image editor, initial focus does not follow the above best practice. Instead, it is set on the image 'crop area'.
To reproduce:
- Edit a post that contains an Image block.
- Select the image block and acitvate the 'Crop' button in the block toolbar.
- The 'Edit media' modal dialog opens.
- Initial focus is not visible. To test it: press the Tab key once. Observe focus goes to the first 'resize handle' within the crop area that shows the image.
I'm attaching a video recording while using VoiceOver, to illustrate that when pressing the Tab key focus goes to the resize handles.
I'm also attaching a screenshot where I made the focus style of the 'crop area' visible by using a red outline.
Note that the 'Crop area' is a focusable div elements with the following attributes:
- tabindex="0"
- role="group"
- aria-label="Crop area"
which is OK, but it should not receive initial focus.
Attachments (2)
Change History (10)
This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.
5 weeks ago
This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.
4 weeks ago
#4
@
4 weeks ago
This needs to be reported upstream for Gutenberg; @abcd95 would you be willing to open an issue in Gutenberg for it?
#5
@
4 weeks ago
Yes, absolutely. I’ve opened an issue in Gutenberg to report this upstream. Thank you for pointing this out.
#6
@
4 weeks ago
Fix up here: https://github.com/WordPress/gutenberg/pull/81541
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
I traced this, and it seems like the source might be in Gutenberg (packages/media-editor)
The crop area's
tabIndex={0}and role="group" markup is correct; it should be keyboard-reachable, just not the initial focus target when the dialog opens.The simplest fix should be to remove
focusOnMount: truefromMediaEditorCanvas, and addfocusOnMount="firstContentElement"to the<Modal>inMediaEditorModal. This is consistent with howCreateTemplatePartModalhandles focus, and with the classic image editor's focusManager() which explicitly targets the first toolbar control rather than the image canvas.