fix: allow first table drag interaction #10423 - #10602
anu-priya-1999 wants to merge 4 commits into
Conversation
|
Looks like this is failing a test |
snowystinger
left a comment
There was a problem hiding this comment.
What did
keyboardNavigationBehavior="tab"
have to do with this? seems like mouse drag would work the same regardless?
Is there an equivalent test to the one that was failing that showed the opposite? Or do you have a test that shows the original issue with both keyboardNavigationBehavior behaviours set?
|
You're right — keyboardNavigationBehavior itself isn't relevant to the mouse drag interaction. I initially added keyboardNavigationBehavior !== 'tab' because the existing S2 test (textfield in cell works with tab mode) started failing with my first version of the fix. I confirmed that this test passed before the change, failed after the first commit, and passed again after the workaround was adjusted. I then changed the implementation so the workaround is based on the pointer target instead of the keyboard navigation mode. It now only removes the cell's tabIndex when getEventTarget(e) === e.currentTarget, so the behavior is tied to a direct interaction with the cell rather than to keyboardNavigationBehavior. I also ran the affected test suites successfully: packages/@react-spectrum/s2/test/TableView.test.tsx Both suites pass with the updated implementation. |
Summary
Fixes #10423
Fixes an issue where the first drag interaction on a draggable React Aria Table row could fail when initiated from the row's drag handle.
Root cause
useGridCelltemporarily removes the cell'stabIndexon pointer down when selection occurs on press up. This prevents the browser from focusing the cell while starting a drag.The logic previously only installed this handler when
gridCellProps.onPointerDownwas not already defined. With the currentuseSelectableItembehavior, the cell can already have anonPointerDownhandler, causing theuseGridCellhandler to be skipped entirely.As a result, the cell keeps its
tabIndexduring the first drag interaction and the drag handle can fail to start the drag correctly.Fix
useGridCellpointer-down handling whenshouldSelectOnPressUpandtabIndexare applicable.onPointerDownhandler instead of replacing it.tabIndexduring pointer interaction.Testing
Added a regression test verifying that the cell's
tabIndexis removed on the first drag interaction and restored afterward.Validated with:
packages/react-aria-components/test/Table.test.js