You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd expect useKeyboardSensor to reset the lock state when it aborts before it can call api.drop() on a Droppable, or phrased another way, I'd expect to be able to tryGetLock after having successfully called tryReleaseLock on the sensorApi.
Actual behavior
useKeyboardSensor only cleans up it's event handlers but doesn't reset the state of the DragDropContext so nothing can get drag-and-dropped until you either refresh or force re-render the parent component.
Steps to reproduce
Make a <DragDropContext sensors={[useNoKeyboardSensors]} /> where useNoKeyboardSensors is the following hook:
functionuseNoKeyboardSensors(api){constabortKeyboardSensor=useCallback((e)=>{if(![" ","Spacebar"].includes(e.key)){return;}constdraggableId=api.findClosestDraggableId(e);if(!draggableId){return;}constcanLock=api.canGetLock(draggableId);if(!canLock){api.tryReleaseLock();}constpreDrag=api.tryGetLock(draggableId);if(preDrag!==null){// unreachable code as of `[email protected]`preDrag.abort();}},[api]);useEffect(()=>{window.addEventListener('keydown',abortKeyboardSensor);return()=>window.removeEventListener('keydown',abortKeyboardSensor);},[abortKeyboardSensor]);}
Suggested solution?
I'm not sure I have any ideas for a good solution to this problem 😞
What version of React are you using?
16.11.0
What version of react-beautiful-dnd are you running?
I think we will fix your issue by allowing you to disable the keyboard sensor. But i think it is also worth looking into the issue you are experiencing too
I'd expect useKeyboardSensor to reset the lock state when it aborts before it can call api.drop() on a Droppable, or phrased another way, I'd expect to be able to tryGetLock after having successfully called tryReleaseLock on the sensorApi.
alexreardon
changed the title
useKeyboardSensor does not surrender sensorApi lock when released/aborted
api.tryReleaseLock does not abort an existing drag
Jan 7, 2020
Expected behavior
I'd expect
useKeyboardSensor
to reset the lock state when it aborts before it can callapi.drop()
on aDroppable
, or phrased another way, I'd expect to be able totryGetLock
after having successfully calledtryReleaseLock
on the sensorApi.Actual behavior
useKeyboardSensor
only cleans up it's event handlers but doesn't reset the state of theDragDropContext
so nothing can get drag-and-dropped until you either refresh or force re-render the parent component.Steps to reproduce
Make a
<DragDropContext sensors={[useNoKeyboardSensors]} />
whereuseNoKeyboardSensors
is the following hook:Suggested solution?
I'm not sure I have any ideas for a good solution to this problem 😞
What version of
React
are you using?16.11.0
What version of
react-beautiful-dnd
are you running?12.2.0
What browser are you using?
Both Chrome Dev and Chrome Stable (v79 and v80)
Demo
https://codesandbox.io/s/vertical-list-c6fod
The text was updated successfully, but these errors were encountered: