lukasbach / react-complex-tree

Unopinionated Accessible Tree Component with Multi-Select and Drag-And-Drop
https://rct.lukasbach.com
MIT License
953 stars 77 forks source link

Multiselect doesn't work on MacOS #160

Closed selfrefactor closed 1 year ago

selfrefactor commented 1 year ago

Latest version 1.1.11 doesn't correctly recognize command button click. The bug was fixed by downgrading to 1.1.10. What is odd is that if I use current state of the repo by copy/paste of core package, then it works. This means that it is not as much for the change of the code, as much as how the bundler(in my case CreateReactApp) is using the new version.

As additional info, it happens on ControlledTreeEnvironment component.

It is very much re-occurrence of https://github.com/lukasbach/react-complex-tree/issues/80

lukasbach commented 1 year ago

Since I don't have a mac, I can't really test or verify this, I don't see any reasons in the code why this would degrade between 1.1.10 and 1.1.11. I'm happy for anyone with a mac who could test this and maybe see where in the code this click gets lost. Note that, in the code, pretty much all that happens is

export const isControlKey = (e: React.MouseEvent<any, any>) =>
  e.ctrlKey ||
  (navigator.platform.toUpperCase().indexOf('MAC') >= 0 && e.metaKey);

within an onClick event, otherwise the logic should be the same for windows and mac, and it seems to work under Windows, so maybe someone with a mac could already verify or report whether there is something not working with this snippet.

Shaglock commented 1 year ago

@lukasbach @selfrefactor on my mac it works correctly, I checked on my project locally and also checked in the storybook https://rct.lukasbach.com/storybook/?path=/story/core-basic-examples--actions, cmd + click works and also cmd+shift+click works, I don't see any problems. Code snippet also returns true when I press cmd, so it works correctly. Tested in Safari and Firefox. Actually in both browsers ctrl+click triggers a context menu, so using cmd is the only way :D

selfrefactor commented 1 year ago

thank you for the information. I will have access to Mac next week, so I will test it personally to assure that this weird issue is gone. I will write again once I know more.

lukasbach commented 1 year ago

Thanks both of you for your investigation, interested to see if it works for you @selfrefactor.

selfrefactor commented 1 year ago

I will close the issue, as I was unable to test it and I don't want to be reason for holding the issue open.