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

Keyboard navigation

Open m1lk1way opened this issue 7 years ago • 4 comments

Is there any way to disable keyboard navigation (using arrow keys when tabs focused) PS: i just want to disable it because of its different behaviour under different browsers.

Shortly - i need to render all <li> without tabindex.... its impossible now

reason - It throws Focus from active tab to body from ported modal after "tab" key (chrome only)

m1lk1way avatar Aug 28 '18 13:08 m1lk1way

By the way i tried to pass tabindex -1 to rendered Tab but it still focusable after mouse click on it

m1lk1way avatar Aug 31 '18 14:08 m1lk1way

UPD as workaround (read - hack) it is possible to remove key navigation by passing custom onKeyDown (and preventing everything there) to Tab component

m1lk1way avatar Sep 03 '18 18:09 m1lk1way

I apologize for not answering more thoroughly — unfortunately my time is very limited at the moment.

The best I can give you right now is: if I was trying to solve this issue, I would look into using the onSelect prop, and cancelling navigation by returning false from the function you pass to it if event.type === 'keydown'. See https://github.com/reactjs/react-tabs#onselect-index-number-lastindex-number-event-event--boolean

My advice is to try that and see where it leads you.

NOTE: I'm pretty sure the README is wrong there and you need to return false, (not true, which is what it says) in order to cancel the navigation. I'll look into this once I have more time, but if you or anyone else finds out this is correct we'd really appreciate and happily merge a PR to fix the docs!

joepvl avatar Sep 03 '18 23:09 joepvl

@joepvl firstly thanks for your answer, it partially solves my problem. At the same time if i want to disable whole navigation, its still possible to navigate to active tab using Tab key because it has tabindex=0 according to this part of code as i understand, there are no hacks for solving this case

m1lk1way avatar Sep 04 '18 10:09 m1lk1way