In some situations when using a keyboard for d'n'd in ListBox/GridList, pressing Esc doesn't return the focus back to the list item that was focused before dragging started.
π€ Expected Behavior?
Pressing Esc reliably returns focus to the focused list item.
π― Current Behavior
Some ListBox/GridList elements lose focus when pressing Esc instead of returning to the list item that was focused before dragging.
Oddly, I found one example in the docs that works correctly, and another identically looking example that consistently fails across browsers and devices.
Possibly in some situations aria-hidden is set to false later than the check is executed.
Removing this check resolves the issue.
It's not clear to me why this check is needed at least for the lists, as it seems like the only situation where aria-hidden might be true is when dragging, and in cancel() we clearly have a situation where dragging stops.
Provide a general summary of the issue here
In some situations when using a keyboard for d'n'd in
ListBox
/GridList
, pressing Esc doesn't return the focus back to the list item that was focused before dragging started.π€ Expected Behavior?
Pressing Esc reliably returns focus to the focused list item.
π― Current Behavior
Some
ListBox
/GridList
elements lose focus when pressing Esc instead of returning to the list item that was focused before dragging.Oddly, I found one example in the docs that works correctly, and another identically looking example that consistently fails across browsers and devices.
π Possible Solution
When dragging starts,
useDroppableItem
setsaria-hidden
totrue
for all items in the list, so that screen readers stop interacting with the list items and instead offer to select the drop position: https://github.com/adobe/react-spectrum/blob/bd458c1ed166a5ff1fd93f0c1a397e1540b3d880/packages/%40react-aria/dnd/src/useDroppableItem.ts#L79Pressing Esc calls
cancel()
inDragManager
, which only returns the focus if the item is notaria-hidden
. https://github.com/adobe/react-spectrum/blob/bd458c1ed166a5ff1fd93f0c1a397e1540b3d880/packages/%40react-aria/dnd/src/DragManager.ts#L537Possibly in some situations
aria-hidden
is set tofalse
later than the check is executed.Removing this check resolves the issue.
It's not clear to me why this check is needed at least for the lists, as it seems like the only situation where
aria-hidden
might betrue
is when dragging, and incancel()
we clearly have a situation where dragging stops.π¦ Context
No response
π₯οΈ Steps to Reproduce
My screen recording of the failure: https://github.com/adobe/react-spectrum/assets/8333702/a39f1c12-19f6-4d95-b45b-3287c6ff293b
The similarly looking list on another page returns the focus. The recording with the correct behavior on this page: https://github.com/adobe/react-spectrum/assets/8333702/b8369e96-1a3a-4231-ab5c-237818077bfb
Version
3.33.1
What browsers are you seeing the problem on?
Chrome, Safari
If other, please specify.
No response
What operating system are you using?
MacOS
π§’ Your Company/Team
No response
π· Tracking Issue
No response