Opened 10 years ago
Closed 10 years ago
#28857 closed defect (bug) (fixed)
Media Grid: Manage focus when toggling between the grid and an edit attachment modal
Reported by: | davidakennedy | Owned by: | wonderboymusic |
---|---|---|---|
Milestone: | 4.0 | Priority: | normal |
Severity: | normal | Version: | 4.0 |
Component: | Media | Keywords: | |
Focuses: | accessibility, javascript | Cc: |
Description (last modified by )
What happened: When I visit /wp-admin/upload.php and navigate using a keyboard only and select any of the items in the Media Libray, focus is shifted to the modal (good!), but if I press esc or the close button to exit the modal, my focus is dumped at the beginning of #wpbody.
What I expected: I would expect the focus to return to the item I was last focused on, in this case, whichever media items I was on.
Steps to reproduce:
- Visit /wp-admin/
- Navigate to a media item via the keyboard by pressing tab.
- Activate the modal by pressing enter.
- Exit the modal by pressing esc or the close button.
Thoughts/Solutions: There are some great thoughts on this and a potential solution here: http://accessibility.oit.ncsu.edu/blog/2014/01/02/incredible-accessible-modal-window-version-2/
Attachments (4)
Change History (19)
This ticket was mentioned in IRC in #wordpress-dev by ericandrewlewis. View the logs.
10 years ago
#3
@
10 years ago
- Summary changed from Add Media: Manage focus better to Media Grid: Manage focus when toggling between the grid and an edit attachment modal
#5
@
10 years ago
- Keywords has-patch dev-feedback added; needs-patch removed
- When opening modal, store the event currentTarget on the model.
- When closing modal, restore focus to closest li (currentTarget is sometimes li, sometimes enclosed image).
- Need to address focus restoration after originally clicked item is deleted from modal.
Here is a screencast, all actions are keyboard driven.
#8
@
10 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
I noticed an issue where if you open the image detail modal, navigate around with the arrows, then close the modal, the focus is not set.
28857.3.diff fixes that - it skips storing the target li at all; instead, when closing the modal it finds the correct li to focus on based on model data.
we still need to address focus when deleting an image from the modal (which right now seems to not close the modal?)
#9
@
10 years ago
- Owner set to wonderboymusic
- Resolution set to fixed
- Status changed from reopened to closed
In 29299:
#10
follow-up:
↓ 11
@
10 years ago
- Keywords needs-patch added; has-patch dev-feedback removed
- Resolution fixed deleted
- Status changed from closed to reopened
We should think about the implementation here more thoroughly.
We should never use global jQuery selectors in Backbone code, this typically implies an object is taking on more responsibility than it can handle.
The task of reestablishing focus on the correct element should probably live within the media.view.MediaFrame.Manage
controller. As this controller opens up the modal via the openEditAttachmentModal
method, it should probably also listen to events happening on that frame to keep track of what attachment is currently being edited/viewed in the modal, and on close reestablish focus appropriately.
#11
in reply to:
↑ 10
@
10 years ago
Good point. I put the focus call inside the close callback because we already had a close callback - I can see how shifting it to a listener in MediaFrame.Manage makes more sense structurally and would allow us to more narrowly focus the selector.
Replying to ericlewis:
We should think about the implementation here more thoroughly.
We should never use global jQuery selectors in Backbone code, this typically implies an object is taking on more responsibility than it can handle.
The task of reestablishing focus on the correct element should probably live within the
media.view.MediaFrame.Manage
controller. As this controller opens up the modal via theopenEditAttachmentModal
method, it should probably also listen to events happening on that frame to keep track of what attachment is currently being edited/viewed in the modal, and on close reestablish focus appropriately.
#12
@
10 years ago
I worked on this a little bit and wound up with far more complicated code that seems harder to maintain; part of the issue is that the modal is repeatedly closed and reopened in resetContent inside MediaFrame.EditAttachments;
Any actions attached to the modal in MediaFrame.Manage are lost when the modal is destroyed/opened. Perhaps watching for the div itself would work, seems more complicated than the current solution.
#13
@
10 years ago
28857.4.diff removes an unused variable that crept in from an earlier patch.
restore focus when closing media grid modal