react-spectrum icon indicating copy to clipboard operation
react-spectrum copied to clipboard

Add drag and drop to react-aria-components `TabList`

Open vovsemenv opened this issue 1 year ago โ€ข 2 comments

Provide a general summary of the feature here

I see dragAndDropHooks in List but don't see it in TabList

๐Ÿค” Expected Behavior?

add dragAndDropHooks={dragAndDropHooks} to TabList

๐Ÿ˜ฏ Current Behavior

๐Ÿ’ Possible Solution

No response

๐Ÿ”ฆ Context

๐Ÿ’ป Examples

No response

๐Ÿงข Your Company/Team

No response

๐Ÿ•ท Tracking Issue

No response

vovsemenv avatar Oct 15 '24 09:10 vovsemenv

Unfortunately Tab lists only allow tabs as children and tabs don't allow interactive children https://w3c.github.io/aria/#tablist

As a result, it's difficult to add an affordance for keyboard users or assistive technology users.

I'm not saying this won't happen eventually, but it won't be as simple as just adding dragAndDropHooks to TabList.

snowystinger avatar Oct 15 '24 20:10 snowystinger

@majornista we briefly discussed the possibility of using Enter as the keyboard affordance to start a drag session since https://www.w3.org/WAI/ARIA/apg/patterns/tabs/examples/tabs-manual/ has Enter and/or Space to change which tab to display but just wanted to check if you had any opinions on the keyboard experience here.

LFDanLu avatar Oct 16 '24 22:10 LFDanLu

Related #5366. It would be very good addition if it was possible to reorder and close tabs by using the tab headers.

I think the keyboard actions could be very similar to GridList.

ttsirkia avatar Nov 01 '24 20:11 ttsirkia

Drag and drop would have to be more like ListBox, not GridList. Like ListBox, Tabs do not allow interactive children within them according to the aria spec. That means we couldn't have a drag button affordance inside them like GridList does. You could potentially trigger drag and drop by pressing Enter on an already selected tab. For the same reason, close buttons can't be supported within Tabs unfortunately.

Another possibility would be to just use GridList styled to look like Tabs instead of the actual Tabs component if they have interactive elements inside them. Not sure that's ideal, but it could be the only valid option until something like the aria-actions proposal is standardized. https://github.com/w3c/aria/issues/1440

devongovett avatar Nov 01 '24 20:11 devongovett

That's actually true that ListBox is a better example here as it doesn't have any visible handle.

It is unfortunate that Aria specs limits the functionality. I didn't try this earlier but noticed that Edge has implemented quite nice keyboard actions: tabs

You can swap the position of the tabs by using Ctrl+left/right arrow. I couldn't get this working with Chrome.

ttsirkia avatar Nov 01 '24 20:11 ttsirkia