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

<Selection> deselects selected object on second click - can't configure to behave differently #1385

Open
soadzoor opened this issue Apr 4, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@soadzoor
Copy link

soadzoor commented Apr 4, 2023

  • three version: 150.1
  • @react-three/fiber version: 8.12.0
  • @react-three/drei version: 9.62.2
  • node version: 18.15.0
  • npm (or yarn) version: 9.5.0

Problem description:

When I select an object using the <Select> component, it works pretty nicely, but when I click on the same object again, it gets deselected. It makes sense in some cases, but for my use-case, it doesn't. Since I'm also providing the ability to drag/grab the object and move it around with the mouse, it's weird how it always gets deselected whenever the user moves it a little bit, so they have to click it again.

I couldn't find a property or option where this behavior could be modified. In fact, I can barely find any documentation on this component, except for some examples I could find on codesandbox.

Relevant code:

https://codesandbox.io/s/ny3p4?file=/src/App.js:475-483

Suggested solution:

Provide an attribute, something like deselectOnSecondClick={false}, which would prevent the above mentioned behavior. Of course, when someone clicks the object with the "shift" key being held, it would make sense for my use-case as well, to deselect the clicked object on the second click, so there might be multiple attributes/properties required to satisfy all the use-cases...

@soadzoor soadzoor added the bug Something isn't working label Apr 4, 2023
@Haschtl
Copy link

Haschtl commented Sep 9, 2023

I had the same issue now.
It's a very simple fix, I created a pull-request for it: #1648

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants