Skip to content

Commit

Permalink
Remove autofocus option
Browse files Browse the repository at this point in the history
  • Loading branch information
i-like-robots committed Nov 30, 2017
1 parent afd26a1 commit 267beba
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 23 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ React.render(<App />, document.getElementById('app'))
- [`tags`](#tags-optional)
- [`suggestions`](#suggestions-optional)
- [`placeholder`](#placeholder-optional)
- [`autofocus`](#autofocus-optional)
- [`autoresize`](#autoresize-optional)
- [`delimiters`](#delimiters-optional)
- [`delimiterChars`](#delimitersChars-optional)
Expand Down Expand Up @@ -113,10 +112,6 @@ const suggestions = [

The placeholder string shown for the input. Default: `'Add new tag'`.

#### autofocus (optional)

Boolean parameter to control whether the text-input should be autofocused on mount. Default: `true`.

#### autoresize (optional)

Boolean parameter to control whether the text-input should be automatically resized to fit its value. Default: `true`.
Expand Down
4 changes: 0 additions & 4 deletions lib/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ class Input extends React.Component {
this.copyInputStyles()
this.updateInputWidth()
}

if (this.props.autofocus) {
this.input.focus()
}
}

componentDidUpdate (prevProps) {
Expand Down
3 changes: 0 additions & 3 deletions lib/ReactTags.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ class ReactTags extends React.Component {
<Input {...this.state}
ref={(c) => { this.input = c }}
listboxId={listboxId}
autofocus={this.props.autofocus}
autoresize={this.props.autoresize}
expandable={expandable}
placeholder={this.props.placeholder} />
Expand All @@ -199,7 +198,6 @@ ReactTags.defaultProps = {
tags: [],
placeholder: 'Add new tag',
suggestions: [],
autofocus: true,
autoresize: true,
delimiters: [KEYS.TAB, KEYS.ENTER],
delimiterChars: [],
Expand All @@ -214,7 +212,6 @@ ReactTags.propTypes = {
tags: PropTypes.arrayOf(PropTypes.object),
placeholder: PropTypes.string,
suggestions: PropTypes.arrayOf(PropTypes.object),
autofocus: PropTypes.bool,
autoresize: PropTypes.bool,
delimiters: PropTypes.arrayOf(PropTypes.number),
delimiterChars: PropTypes.arrayOf(PropTypes.string),
Expand Down
14 changes: 3 additions & 11 deletions spec/ReactTags.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ function $$ (selector) {
}

function type (value) {
$('input').focus()

value.split('').forEach((char) => {
key(char)
$('input').value += char
Expand Down Expand Up @@ -94,16 +96,6 @@ describe('React Tags', () => {
expect($('input').placeholder).toEqual('Please enter a tag')
})

it('autofocuses on the input', () => {
createInstance({ autofocus: true })
expect(document.activeElement).toEqual($('input'))
})

it('does not autofocus on the input', () => {
createInstance({ autofocus: false })
expect(document.activeElement).not.toEqual($('input'))
})

it('updates state when suggestions list is expanded', () => {
createInstance()

Expand Down Expand Up @@ -131,7 +123,7 @@ describe('React Tags', () => {
})

it('calls focus and blur callbacks when provided', () => {
createInstance({ autofocus: false })
createInstance()

TestUtils.Simulate.focus($('input'))
sinon.assert.calledOnce(props.handleFocus)
Expand Down

0 comments on commit 267beba

Please sign in to comment.