-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom keyboard bindings #40
Comments
Would you be receptive to a patch that allows the developer to customize whether the For List-based controls I've built in the past, I've modeled it after a radio button group where pressing tab will enter the list but the user uses the arrow keys to navigate between items. Perhaps we could discuss a somewhat future-proofed API that allows for keyboard bindings to be either disabled or customized? |
The tab index allows keyboard users to get to the draggable item. You are welcome to build your custom logic on top of this library. You can patch type DragHandleProvided = {|
onMouseDown: (event: MouseEvent) => void,
onKeyDown: (event: KeyboardEvent) => void,
onClick: (event: MouseEvent) => void,
tabIndex: number,
'aria-grabbed': boolean,
draggable: boolean,
onDragStart: () => void,
onDrop: () => void
|} |
@alexreardon thanks for your reply and the nudge. After studying the code a bit more, I realized that With respect to the ancillary discussion about tabs vs. arrow keys, I would just offer this example from the W3C Aria specs: https://www.w3.org/TR/wai-aria-practices/examples/listbox/listbox.html They recommend reserving the tab key for moving between controls, and using arrow keys to move between elements within the control. I acknowledge they aren't trying to address the more complex dnd interaction in this spec, although considering their guidelines might still be useful. If you're willing to revisit that, please ping me as I'd be interesting in assisting with the PR if possible. |
Thanks for this @cliffmeyers, we'll definitely take this into consideration when we revisit this feature :) |
I'd love to see this implemented. Some reasoning after fiddling with the current implementation. Would be nice to have keys configurable for:
One of the main reasons for this is that I have a use case where a Draggable contains text-editable content. While the user is writing, without having to focus out of their writing interaction, I'd like to give the ability to start a drag and finish it, while they're text editing (text never loses focus and cursor). Right now, while the focus is on the inner text element (an input or a contenteditable that lives inside a Draggable) I need to either disable dragging of the Draggable with isDisabled, or capture the event and stop its propagation, given that the spacebar is an obviously useful character to type while writing text :) If I don't do any of these options the spacebar key is captured as a drag start and the user can't type it in. It would be really nice to be able to reconfigure the start drag with CTRL key. Bonus 1 HOLD/RELEASE DRAG KEY TO KEEP DRAG Bonus 2 MULTIPLE KEYS FOR EACH EVENT Bonus 3 FIX USABILITY OF CURRENT DRAGGING STATE More about previous point: Actual behaviorSpacebar is by default the only way to start a keyboard drag, finish it and cancel it. Not configurable. Thank you! |
I'm also really interested in reconfiguring the shortcut for lifting a draggable. We're building a video editing system, where If you're open to having it configurable I'd be happy to make a PR. |
I'd appreciate this. I've just migrated from react-sortable-hoc, which does provide this. I would want to keep all the existing key shortcuts, but also add:
|
Hey folks 👋 Since v13.1.0, applying custom key bindings is possible by creating a custom keyboard sensor. Alex has created a wonderful guide here, please have a read 🙏. Note that when you provide custom sensors to the |
Thanks for the wonderful work y'all are doing. I have been reading through Alex's guide to see if I need to create a custom keyboard sensor, but I'm also trying to figure if there is another way to accomplish what I'm trying to do. For the app I'm working on, I want to have some additional styles around the Draggable IF the drag is initiated by keypress for visual keyboard users (a small hint as to how the keyboard controls work, and arrow icons to suggest the user type the arrow up/down key to reorder). For screen-reader / keyboard users, I the needed directions are provided, but for visual keyboard users, there isn't currently a hint being displayed. If the user is starting the drag via mouse click, I don't want to show this information. I'm looking for a way to determine the type of event ( If I do need to build my own sensor, is there a way to just |
Add the ability to provide your own key bindings.
Still unsure if this is the right thing to do given that it is really easy to do the wrong thing by the browser - but we will investigate it!
The text was updated successfully, but these errors were encountered: