Skip to content

Commit da6f2ec

Browse files
committed
Remove autofocus option
1 parent 508db72 commit da6f2ec

File tree

4 files changed

+3
-23
lines changed

4 files changed

+3
-23
lines changed

README.md

-5
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ React.render(<App />, document.getElementById('app'))
7070
- [`tags`](#tags-optional)
7171
- [`suggestions`](#suggestions-optional)
7272
- [`placeholder`](#placeholder-optional)
73-
- [`autofocus`](#autofocus-optional)
7473
- [`autoresize`](#autoresize-optional)
7574
- [`delimiters`](#delimiters-optional)
7675
- [`delimiterChars`](#delimitersChars-optional)
@@ -113,10 +112,6 @@ const suggestions = [
113112

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

116-
#### autofocus (optional)
117-
118-
Boolean parameter to control whether the text-input should be autofocused on mount. Default: `true`.
119-
120115
#### autoresize (optional)
121116

122117
Boolean parameter to control whether the text-input should be automatically resized to fit its value. Default: `true`.

lib/Input.js

-4
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ class Input extends React.Component {
3030
this.copyInputStyles()
3131
this.updateInputWidth()
3232
}
33-
34-
if (this.props.autofocus) {
35-
this.input.focus()
36-
}
3733
}
3834

3935
componentDidUpdate (prevProps) {

lib/ReactTags.js

-3
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ class ReactTags extends React.Component {
178178
<Input {...this.state}
179179
ref={(c) => { this.input = c }}
180180
listboxId={listboxId}
181-
autofocus={this.props.autofocus}
182181
autoresize={this.props.autoresize}
183182
expandable={expandable}
184183
placeholder={this.props.placeholder} />
@@ -199,7 +198,6 @@ ReactTags.defaultProps = {
199198
tags: [],
200199
placeholder: 'Add new tag',
201200
suggestions: [],
202-
autofocus: true,
203201
autoresize: true,
204202
delimiters: [KEYS.TAB, KEYS.ENTER],
205203
delimiterChars: [],
@@ -214,7 +212,6 @@ ReactTags.propTypes = {
214212
tags: PropTypes.arrayOf(PropTypes.object),
215213
placeholder: PropTypes.string,
216214
suggestions: PropTypes.arrayOf(PropTypes.object),
217-
autofocus: PropTypes.bool,
218215
autoresize: PropTypes.bool,
219216
delimiters: PropTypes.arrayOf(PropTypes.number),
220217
delimiterChars: PropTypes.arrayOf(PropTypes.string),

spec/ReactTags.spec.js

+3-11
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ function $$ (selector) {
5050
}
5151

5252
function type (value) {
53+
$('input').focus()
54+
5355
value.split('').forEach((char) => {
5456
key(char)
5557
$('input').value += char
@@ -94,16 +96,6 @@ describe('React Tags', () => {
9496
expect($('input').placeholder).toEqual('Please enter a tag')
9597
})
9698

97-
it('autofocuses on the input', () => {
98-
createInstance({ autofocus: true })
99-
expect(document.activeElement).toEqual($('input'))
100-
})
101-
102-
it('does not autofocus on the input', () => {
103-
createInstance({ autofocus: false })
104-
expect(document.activeElement).not.toEqual($('input'))
105-
})
106-
10799
it('updates state when suggestions list is expanded', () => {
108100
createInstance()
109101

@@ -131,7 +123,7 @@ describe('React Tags', () => {
131123
})
132124

133125
it('calls focus and blur callbacks when provided', () => {
134-
createInstance({ autofocus: false })
126+
createInstance()
135127

136128
TestUtils.Simulate.focus($('input'))
137129
sinon.assert.calledOnce(props.handleFocus)

0 commit comments

Comments
 (0)