components/switcher-form: listen to keydown events instead of keyup
This reduces perceived input delay and allows key repeat to occur. Co-authored-by: handlerug <handlerug@handlerug.me> Co-committed-by: handlerug <handlerug@handlerug.me>
This commit is contained in:
@@ -65,7 +65,7 @@ export default class SwitcherForm extends Component {
|
|||||||
|
|
||||||
this.handleInput = this.handleInput.bind(this);
|
this.handleInput = this.handleInput.bind(this);
|
||||||
this.handleSubmit = this.handleSubmit.bind(this);
|
this.handleSubmit = this.handleSubmit.bind(this);
|
||||||
this.handleKeyUp = this.handleKeyUp.bind(this);
|
this.handleKeyDown = this.handleKeyDown.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
getSuggestions() {
|
getSuggestions() {
|
||||||
@@ -106,7 +106,7 @@ export default class SwitcherForm extends Component {
|
|||||||
this.props.onSubmit(this.getSuggestions()[this.state.selected]);
|
this.props.onSubmit(this.getSuggestions()[this.state.selected]);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleKeyUp(event) {
|
handleKeyDown(event) {
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
case "ArrowUp":
|
case "ArrowUp":
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
@@ -152,7 +152,7 @@ export default class SwitcherForm extends Component {
|
|||||||
<form
|
<form
|
||||||
onInput=${this.handleInput}
|
onInput=${this.handleInput}
|
||||||
onSubmit=${this.handleSubmit}
|
onSubmit=${this.handleSubmit}
|
||||||
onKeyUp=${this.handleKeyUp}
|
onKeyDown=${this.handleKeyDown}
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
type="search"
|
type="search"
|
||||||
|
|||||||
Reference in New Issue
Block a user