Skip to content

Commit

Permalink
Merge pull request #181 from i-like-robots/delimiters-for-soft-keyboards
Browse files Browse the repository at this point in the history
Delimiters for soft keyboards
  • Loading branch information
i-like-robots authored Nov 1, 2019
2 parents 585186e + c07922a commit f9b60ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Refactored event handlers and callbacks to use `on` prefixes
- Refactored `classNames` option to avoid creating new and merging objects for each top-level props change
- Refactored `deleteTag` method so it no longer clears the input text when a tag is removed
- Refactored `delimiters` option to be an array of `KeyboardEvent.key` values
- Removed `clearInputOnDelete` option
- Removed `autofocus` option
- Removed `delimiterChars` option
Expand Down
11 changes: 10 additions & 1 deletion lib/ReactTags.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,16 @@ class ReactTags extends React.Component {
this.props.onInput(query)
}

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

0 comments on commit f9b60ae

Please sign in to comment.