Skip to content

Conversation

@romansndlr
Copy link
Contributor

@romansndlr romansndlr commented Apr 30, 2025

In some cases when using the default selection behavior for the ListBox which is toggle in multi selection mode, you want the ability to clear out all existing selections and only "focus" on one option.

As I see it, this is complimentary to the existing feature where it is possible to switch to "toggle" mode when holding ctrl/cmd in selection behavior replace. This is essentially the inverse of that behavior.

Roman Sandler added 4 commits April 30, 2025 16:45
@romansndlr romansndlr changed the title Add select only option to listbox toggle mode feat: add select only option to listbox toggle mode Apr 30, 2025
@eyalcohen4
Copy link

we really need this in our Multi Select component :)

@romansndlr
Copy link
Contributor Author

@devongovett @LFDanLu Would love to get your review on this one 🙏

@snowystinger
Copy link
Member

To clear the selection, wouldn't you press Esc? I'm not sure I've come across this particular keyboard behaviour before, but maybe I never knew about it, do you have some examples in the real world or specs that outline this behaviour for aria?

@romansndlr
Copy link
Contributor Author

To clear the selection, wouldn't you press Esc? I'm not sure I've come across this particular keyboard behaviour before, but maybe I never knew about it, do you have some examples in the real world or specs that outline this behaviour for aria?

Thanks for the review! Yeah, you could clear and then set but this solution romoves the need for that extra step.

One example I'm aware of is the layers panel in Illustrator I think. If you hold meta and click on the eye icon it should behave in a similar way.

@snowystinger
Copy link
Member

The selection behaviour for the layers panel in Illustrator appears to be doing the same thing as selectionBehavior="replace"
https://react-spectrum.adobe.com/react-aria/ListBox.html#selection-behavior

Steps:

  1. click Tomato
  2. shift click Egg Salad
  3. click Cheese
    Result:
    only Cheese is selected

Steps:

  1. click Tomato
  2. shift click Egg Salad
  3. command click Tuna Salad
    Result:
    Tomato, Cheese, and Egg Salad are selected

I repeated the same steps in an Illustrator document with multiple layers.

Update:
And I just realized I was selecting the objects, not the layers. This confusion https://community.adobe.com/t5/illustrator-discussions/can-someone-explain-selecting-layers-objects/td-p/9147082
Will need to discuss this with the team. If you have any less confusing examples, that'd help the case.

@snowystinger
Copy link
Member

I tried bringing this up with the team today and found that the Illustrator use case was all behaving like selectionBehavior="replace", I'm not sure if I did something differently last time or if they updated the app?

The "eye" is always the same behavior, regardless of meta key from what I can tell.

I'm not sure if there is anything to do here anymore. Will need new reproduction instructions.

Finally, the only selection in the layers panel is the highlighting. The other two, eye and object, are independent of collection selection and should be implemented on the application side.

@romansndlr
Copy link
Contributor Author

I tried bringing this up with the team today and found that the Illustrator use case was all behaving like selectionBehavior="replace", I'm not sure if I did something differently last time or if they updated the app?

The "eye" is always the same behavior, regardless of meta key from what I can tell.

I'm not sure if there is anything to do here anymore. Will need new reproduction instructions.

Finally, the only selection in the layers panel is the highlighting. The other two, eye and object, are independent of collection selection and should be implemented on the application side.

Fair enough. Closing then.

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.

3 participants