react-aria: useSelectableList - how to disable temporary? #3102
Replies: 3 comments 16 replies
-
Hey, thanks for the discussion. I’m not sure you’re using the right thing to accomplish what you want. First off, useSelectableCollection, while publicly available, isn’t meant for general consumption yet. We’re still working out details with it, but we need it in many of our components and hooks, so it must be publicly available. Second, I’m not sure what this system is that you’ve created. What aria pattern is it implementing? Or what component does it take inspiration from? In contrast, we’re currently working on ListView, which also has selection and allows for both |
Beta Was this translation helpful? Give feedback.
-
Thanks for the reply! I used it based on your presentation at axe-con. I know you mentioned there as well that it's not quite ready for public consumption. I was considering ListBox, however I stopped when reading this
useGrid though is also not yet in the public documentation. What I'm implementing is a list of cards. Once a card is selected, further interactive elements become available. I don't know if there is an aria pattern for what we're building on the parent of this list. Maybe I can best describe it as an extension of a skip links pattern, where the first tab will prompt you to deciding whether you want to go to the nav, or the main content. On a page with many interactive elements, we now want to give the user the option to tab from section to section, then dive into the section they are interested in. To achieve this, I would like to have tabIndex=0 only on the sections, and any interactive elements within using tabIndex=-1 until they press enter to interact with that section. So I want to be able to prevent the entire list from receiving keyboard focus until that happens. We have this working with the more simple elements in a section (buttons, menu). An alternative I suppose would be to programmatically move the focus from section to section. I thought I'd be able to avoid that. (Might have to create on what to do with the last section in this case) |
Beta Was this translation helpful? Give feedback.
-
@snowystinger I have a followup question. I've made quite some progress, though stuck on one thing. Our list of cards are editable, so the text may turn into a textarea or input. This should be fine in a grid, right? However, we noticed that when typing into the text field, the collator would intercept, and interpret that as search, and focus another item. We removed the collator, and most of that went away. Haven't dug in whether there's a way to configure that it doesn't do that when focus is on a textarea/input element. However, even after removing the collator, there is still a weird thing about pressing space. If I press and release space quickly, it doesn't stick. Like a global event handler is still intercepting that. If I press a bit longer, then release, it works - the repeater shouldn't have kicked in yet. I've looked a bit in usePress.ts, which may handle this, but it seems like |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
We've devised a system where you tab from section to section, then press enter to drill down/activate the section, then can tab though the elements, and press esc to go back up a level.
To make this work, I need to disable the keyboard navigation for elements in each section. For regular elements, that's easy with
tabIndex={-1}
.How can I accomplish this for a list built with
useSelectableList
? There doesn't seem to be a way to disable the list as a whole.I seem to be able to mostly achieve it by marking all keys as disabled:
This works initially. The list is keyboard disabled. I can then activate the drill down mode, tab to the list, select an item.
However when I then press ESC to exit out, the selected item remains having
tabIndex={0}
, so breaking my system.I can set
tabIndex={-1}
on each list item.Surprisingly this works better, as something else is still changing tabIndex back to 0.
It's not quite a solution though.
Now I select the section, press enter, tab to focus the list, esc to exit, tabbing goes to next section. Tab back, enter, tab again, now the list is selected instead of the item. I tab forward, then back, now the item is properly selected again.
It seems like I'm rather close, just missing some little detail
Beta Was this translation helpful? Give feedback.
All reactions