Can I sort a ListState
based on selected items (useListState)
#7658
Unanswered
calthejuggler
asked this question in
Q&A
Replies: 1 comment
-
Something like this might be useful to you https://reactspectrum.blob.core.windows.net/reactspectrum/3e1c5183f96d1e5b9af14630ab8ddf7dab691962/storybook/index.html?path=/story/react-aria-components--autocomplete-in-popover-dialog-trigger&providerSwitcher-express=false But specifically the "Recently Visited" example in that story, you could probably do something similar but keep those as selected. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello there!
I have created a "MultipleSelect" component that is a bit of a cross between a select and a combobox. It works pretty well, but I'm hoping to find a way to sort the items in the list so that, when you select an item, it goes to the top of the list.
I was thinking I would be able to do it by hacking around with the
children/items
props, but I realise I don't yet know which items are selected because theselectionManager
hasn't been created.I'm trying to make it as similar to (y)our Select component as possible, so it is just as generic. I tried overriding the
onSelectionChange
function, but the ListState doesn't seem to have the same prepend functionality that I was expecting.Is there an easy way to do this that I'm missing? Maybe a list state isn't what I should be using. Thanks in advance for any advice!
Here is the component as it is now:
and here is what it looks like:
Also, if anybody sees any a11y wins that I could make here, I'd love to hear them 🙂
Beta Was this translation helpful? Give feedback.
All reactions