Skip to content
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: allow configuring when to use the 'copy' dropEffect #3498

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

TheUnlocked
Copy link

Allows using keys other than alt to set the dropEffect to 'copy', and allows using a predicate callback in case the user wants more complex behavior.

Resolves #2979

Comment on lines 40 to 51
if (this.optionsArgs?.copyKey === undefined) {
return e.altKey
}
switch (this.optionsArgs?.copyKey) {
case 'shift':
return e.shiftKey
case 'ctrl':
return e.ctrlKey
case 'alt':
return e.altKey
case 'meta':
return e.metaKey

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (this.optionsArgs?.copyKey === undefined) {
return e.altKey
}
switch (this.optionsArgs?.copyKey) {
case 'shift':
return e.shiftKey
case 'ctrl':
return e.ctrlKey
case 'alt':
return e.altKey
case 'meta':
return e.metaKey
switch (this.optionsArgs?.copyKey) {
case 'shift':
return e.shiftKey
case 'ctrl':
return e.ctrlKey
case undefined:
case 'alt':
return e.altKey
case 'meta':
return e.metaKey

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this won't type check without a non-null assertion which is forbidden by the linter. Seems to be a TypeScript issue (minimal reproduction: https://www.typescriptlang.org/play?ts=4.9.0-dev.20221007#code/CYUwxgNghgTiAEYD2A7AzgF3gDwFzwG94AjWAfgAoBKfANyQEth4BfeAH3gFcVQAzBihDAA3ACg+PMBgap4fJEmqEx8NfDQB3BhjAALeBWxkAdKRhUV664ihoEPfoOG5VN93AxcYKcdZZuathmsNTiAUA).

There was an unnecessary optional chaining operator there though which I've removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shift instead of Alt to copy?
2 participants