Media Library: Reset state when losing focus
See original GitHub issueBug Description
If we open the media element dropdown menu from keyboard and then close it by pressing Esc
key, the focus moves to the canvas but the media dropdown (3 dots) button keeps visible. ( See attached video )
Addition: pressing Esc
doesn’t reset the element tabindex
, so when someone tries to refocus the media element, it doesn’t start with the first element. ( See 2nd video )
Expected Behaviour
Pressing onEsc
key either should refocus the media element, or it shouldn’t show the menu button when the focus gets moved to the canvas; plus it should reset the tabindex
.
Steps to Reproduce
- Focus any media element
- Press
Space
key - Press
Esc
key
Screenshots
Additional Context
- Plugin Version: 1.16.0-alpha.0
- WordPress Version: 5.8.2
- Operating System: macOS Monterey (M1)
- Browser: Chrome
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Return iPhone settings to their defaults - Apple Support
Go to Settings > General > Transfer or Reset iPhone > Reset. Choose an option: ... No data or media are deleted. Reset...
Read more >React.js - input losing focus when rerendering - Stack Overflow
The reason input was losing focus in my case was due to the fact that I was re-rendering the input on state change....
Read more >Allow newly uploaded files to be deleted from the media ...
Hover state of the remove buttons. Focus state: Focus state of the remove buttons. Message after removing an item: Message after removing an ......
Read more >How to reset a TextInput field after a Screen is unfocused
Resetting an input field value when a screen loses its focus from being the current screen to another screen in the app is...
Read more >Save UI states - Android Developers
Managing UI state: divide and conquer · Local persistence: Stores all the application data you don't want to lose if you open and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hmm I suppose that makes sense 🤔
We can consult with a11y folks if this comes up again.
At least that’s what I thought! I believe that’s how the roving tab index util and also custom navigation handlers are implemented currently. But perhaps it was always a bug, I just didn’t know.
I can create a general issue for it if it’s a bug – we’re using the same logic everywhere currently, in all library panes, in color picker, calendar, etc.
E.g. when I tab out of the library (or a group of colors in the color picker) and then click
Shift + Tab
to get back, I’d expect to jump back to where I was. If we’d reset the tab indexes when losing focus, I’d end up on the first element instead.Thoughts?