Skip to content
This repository was archived by the owner on Dec 23, 2022. It is now read-only.

Commit 1561f7f

Browse files
authored
Merge pull request #74 from cauld/master
handleInputBlur must pause before checking autocomplete status to support openOnFocus (issue #73)
2 parents 16f9809 + 8703625 commit 1561f7f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/ChipInput.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,18 @@ class ChipInput extends React.Component {
218218
if (this.props.onBlur) {
219219
this.props.onBlur(event)
220220
}
221-
if (!this.autoComplete.state.open || this.autoComplete.requestsList.length === 0) {
221+
222+
//A momentary delay is required to support openOnFocus. We must give time for the autocomplete
223+
//menu to close before checking the current status. Otherwise, tabbing off the input while the
224+
//menu is open results in the input keeping its focus styles.
225+
setTimeout(() => {
226+
if (!this.autoComplete.state.open || this.autoComplete.requestsList.length === 0) {
222227
if (this.props.clearOnBlur) {
223228
this.setState({ inputValue: '' })
224229
}
225230
this.setState({ isFocused: false })
226231
}
232+
}, 0);
227233
}
228234

229235
handleInputFocus = (event) => {

0 commit comments

Comments
 (0)