react-dnd / react-dnd

Drag and Drop for React
http://react-dnd.github.io/react-dnd
MIT License
20.98k stars 1.99k forks source link

Modifier keys accidentally can overwrite dropEffect set in useDrag #1508

Open blaues0cke opened 5 years ago

blaues0cke commented 5 years ago

Describe the bug The user is accidentally able to overwrite the dropEffect using the ⌘ command when the dropEffect is "forced" by passing it in options in useDrag.

Reproduction https://codesandbox.io/s/github/react-dnd/react-dnd/tree/gh-pages/examples_hooks_js/05-customize/drop-effects?from-embed

Steps to reproduce the behavior:

  1. Open https://codesandbox.io/s/github/react-dnd/react-dnd/tree/gh-pages/examples_hooks_js/05-customize/drop-effects?from-embed
  2. Drag the second box with the text When I am over a drop zone, I have no icon and press the modifier keys (⌥ option or ⌘ command). Nothing will change as expected.
  3. Drag the first box with the text When I am over a drop zone, I have copy icon and press the modifier keys (⌥ option or ⌘ command). The "copy" mouse cursor will disappear while pressing ⌘ command. This will also allowing moving where no moving should be allowed.

Expected behavior I expect that in the "copy" mouse cursor will stay since the user should not be allowed to change dropEffect when its defined in options.

Screenshots Screen Recording 2019-08-09 at 12 47 30 2019-08-09 12_48_18

Desktop:

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

blaues0cke commented 5 years ago

This is still an issue I would like to discuss about. :-)

designbyadrian commented 4 years ago

I'm not a maintainer, but I'd like to point out that it looks like you're linking the original example, not your edit?

blaues0cke commented 4 years ago

@designbyadrian Jep, this just happens in the original example without any changes :-)

designbyadrian commented 4 years ago

OIC! Well, CMD and CTRL are meta keys, so maybe it's intentional that they override the action, as CMD isn't the copy key in macOS?

The copy state doesn't change if you toggle the ALT/Option key, at least not in Safari or Chrome.

blaues0cke commented 4 years ago

Yes, this is another issue: The modifier key is hardcoded to "alt" but the modifier key is actually different between macOS (alt) and Windows (ctrl). I created this (https://github.com/react-dnd/react-dnd/issues/1517) issue for that that unfortunately has been closed automatically