Skip to content

Commit f9b60ae

Browse files
Merge pull request #181 from i-like-robots/delimiters-for-soft-keyboards
Delimiters for soft keyboards
2 parents 585186e + c07922a commit f9b60ae

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- Refactored event handlers and callbacks to use `on` prefixes
1414
- Refactored `classNames` option to avoid creating new and merging objects for each top-level props change
1515
- Refactored `deleteTag` method so it no longer clears the input text when a tag is removed
16+
- Refactored `delimiters` option to be an array of `KeyboardEvent.key` values
1617
- Removed `clearInputOnDelete` option
1718
- Removed `autofocus` option
1819
- Removed `delimiterChars` option

lib/ReactTags.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,16 @@ class ReactTags extends React.Component {
112112
this.props.onInput(query)
113113
}
114114

115-
if (query !== this.state.query) {
115+
// NOTE: This test is a last resort for soft keyboards and browsers which do not
116+
// support `KeyboardEvent.key`.
117+
// <https://bugs.chromium.org/p/chromium/issues/detail?id=763559>
118+
// <https://bugs.chromium.org/p/chromium/issues/detail?id=118639>
119+
if (
120+
query.length === this.state.query.length + 1 &&
121+
this.props.delimiters.indexOf(query.slice(-1)) > -1
122+
) {
123+
pressDelimiter.call(this)
124+
} else if (query !== this.state.query) {
116125
const options = getOptions.call(this, query)
117126
this.setState({ query, options })
118127
}

0 commit comments

Comments
 (0)