Add debounce to Tag Search (#6327) [deploy]

This commit is contained in:
Molly Struve 2020-02-27 16:56:49 -05:00 committed by GitHub
parent 32e30c8844
commit fdb8e131ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,5 +1,6 @@
import { h, Component } from 'preact';
import PropTypes from 'prop-types';
import debounce from 'lodash.debounce';
const KEYS = {
UP: 'ArrowUp',
@ -28,6 +29,9 @@ const LETTERS_NUMBERS = /[a-z0-9]/i;
class Tags extends Component {
constructor(props) {
super(props);
this.debouncedTagSearch = debounce(this.handleInput.bind(this), 150);
this.state = {
selectedIndex: -1,
searchResults: [],
@ -439,7 +443,7 @@ class Tags extends Component {
placeholder={`${maxTags} tags max, comma separated, no spaces or special characters`}
autoComplete="off"
value={defaultValue}
onInput={this.handleInput}
onInput={this.debouncedTagSearch}
onKeyDown={this.handleKeyDown}
onBlur={this.handleFocusChange}
onFocus={this.handleFocusChange}