2.0.3 • Published 8 years ago

no-tab v2.0.3

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

NoTab

NoTab is a pair of react components inspired by https://github.com/ChrisWren/touch-input-nav, (though with less functionality as of now). Whenever a user focuses a form field, NoTab uses React's context to disable surrounding form fields to prevent weird (iOS) tabbing behavior. Checkout the blog post for the full story, and the example page to see it in action.

tldr; Normally setting a negative tab index is enough to prevent tabbing... except on iOS

####Basic Usage NoTab is made up of two parts: a higher-order (H-O) component that wraps around whatever form(s) you're dealing with, and a H-O component that wraps each individual input/component for enabling/disabling it.

import { setupFormInput } from 'no-tab';

// The H-O component will pass the disabled prop to whatever it wraps, so at a minimum
// NoTab needs a component that passes its props to an input.
const NoTabInput = setupFormInput(props => <input {...props}/>)

// BAD: Won't Work
const derp = setupFormInput(<input/>)

As mentioned above, your NoTab inputs should be wrapped in a viewContainer somewhere higher up the tree. Two inputs with different formIds inside the same viewContainer won't be tabbable to one another when either is focused.

import { setupViewContainer } from 'no-tab';

const BasicExampleView = setupViewContainer(
    () => (
        <div className="example-view">
            <h3>Basic Example</h3>
            <NoTabInput formId="a"/>
            <NoTabInput formId="b"/>
            <NoTabInput formId="c"/>
            <NoTabInput formId="d"/>
        </div>
    )
);

Checkout the example source to see both sides working together...

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago