Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add enter key handler to dictionary keys #4140

Merged
merged 2 commits into from
Nov 30, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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