Skip to content

Commit

Permalink
Add enter key handler to dictionary keys (#4140)
Browse files Browse the repository at this point in the history
  • Loading branch information
williamw2 authored Nov 30, 2020
1 parent e5b3545 commit bc0bb03
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class Dictionary extends React.Component<
}
onFocus={this.handleKeyFocus(propertyName)}
onBlur={this.handleKeyBlur(propertyName)}
onKeyDown={this.handleKeyPress()}
onChange={this.handleKeyChange(propertyName)}
/>
<button
Expand Down Expand Up @@ -229,6 +230,15 @@ class Dictionary extends React.Component<
};
};

private handleKeyPress = (): ((e: React.KeyboardEvent<HTMLInputElement>) => void) => {
return (e: React.KeyboardEvent<HTMLInputElement>): void => {
if (e.keyCode === 13) {
e.currentTarget.blur();
e.preventDefault();
}
};
};

private handleKeyChange = (
propertyName: string
): ((e: React.ChangeEvent<HTMLInputElement>) => void) => {
Expand Down

0 comments on commit bc0bb03

Please sign in to comment.