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

Support automatic activation of tabs

Open dgreene1 opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe.

When using a keyboard to navigate tabs, the new tab does not become active until you press enter or space.

W3 says:

It is recommended that tabs activate automatically when they receive focus as long as their associated tab panels are displayed without noticeable latency. This typically requires tab panel content to be preloaded. Otherwise, automatic activation slows focus movement, which significantly hampers users' ability to navigate efficiently across the tab list. For additional guidance, see § 6.4 Deciding When to Make Selection Automatically Follow Focus.

(link)

Describe the solution you'd like A clear and concise description of what you want to happen.

A new property would be added to TabProps called activationMode that would be of type "automatic" | "manual". This property would be optional and would default to "manual" since that is the current behavior.

When activationMode: "automatic", if you pressed the right arrow key on the keyboard to cycle through the tabs, the tab panel that is associated with that tab would be shown.

We can consider linking this feature to the persistent flag since the W3 quote above shows that you shouldn't use automatic activation unless the component has been pre-rendered.

Describe alternatives you've considered

I haven't considered any other options.

Additional context none

dgreene1 avatar May 16 '22 20:05 dgreene1

I believe this feature has been implemented but on the Tabs component instead of the Tab itself by enabling the automatic prop. The Configurable Tabs Demo can be used to preview that functionality and with the persistent flag as well. Maybe it would be better for me to simplify the example and showcase the selection mode as a separate demo.

That being said, I like the activationMode: "manual" | "automatic" naming more than automatic: boolean, so I'll probably rename that prop in the future.

mlaursen avatar May 17 '22 00:05 mlaursen