-
Notifications
You must be signed in to change notification settings - Fork 983
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
feat: Add activationKeyCodes to configure the keyboard shortcuts #588
Conversation
What do you think of taking a more holistic approach and making all of the keycodes configurable? Something like: <SortableContainer
keyCodes={{
lift: [32],
drop: [32],
cancel: [27],
up: [38],
down: [40],
}}
/> |
It's interesting, I can definitely see the argument for providing more control. Doing it with one object doesn't play nicely with defaultProps though afaik; you'd have to either use the default set of keys, or redefine all of them, which is a bit awkward. Is there an easy way around that? |
Something like this should probably do the trick: const defaultKeyCodes = {
lift: [32],
drop: [32],
cancel: [27],
up: [38],
down: [40],
};
const {keyCodes: customKeyCodes = {}} = this.props;
const keyCodes = {
...defaultKeyCodes,
...customKeyCodes,
}; |
f36aa21
to
6c2b218
Compare
Sure, that works nicely, done 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, just two minor nitpicks then good to go 👍
6c2b218
to
7bb73bf
Compare
@clauderic all fixed up 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful, will include this in the next release 👍
Released in |
Fixes #584: you can now set
activationKeyCodes
on the sortable container as an array of the keycodes which should be used to activate/deactivate sorting.By default it's
[32]
(just space, as before) and I've tested it working in my app with[32, 13]
(space and enter).