An extremely simple utility to make a container and all its children untabbable, but still focusable.
npm install react-untabbable
``bash`
yarn add react-untabbable
or
`bash`
npm i react-untabbable
* First it obtains all the tabbable elements within a container using the package tabbable
* The current tabindex of each element is saved
* All focusable elements have their tabindex set to __-1__
* When needed, the previous value for the tabindex is restored to the respective elements
The component supports having more than 1 child and you can mix React elements with simples nodes (string, number, etc..).
Elements must support receiving a ref.
| Prop | Type | Default | Description |
|-----------------|-----------|---------|---------------------------------|
| disabled | boolean | false | Restores the tabbable behaviour |
`jsx
import { Untabbable } from 'react-untabbable';
You can mix React elements with simple nodes! (string, number, etc...)
`
| Parameter | Type | Default | Description |
|--------------------------|------------------|---------|---------------------------------------------------|
| ref | ref or ref[] | | One or more refs to DOM elements |object
| options? | | {} | |boolean
| options.disabled | | false | Restores the tabbable behaviour |boolean
| options.includeContainer | | true | If the owner of the ref should also be untabbable |
`jsx
import React, { useRef } from 'react';
import { useUntabbable } from 'react-untabbable';
const MyComponent = () => {
const firstButtonRef = useRef();
const secondButtonRef = useRef();
useUntabbable([firstButtonRef, secondButtonRef]);
return (