Skip to content

Commit

Permalink
[grid] Add ability to use Enter key to confirm (#11178)
Browse files Browse the repository at this point in the history
This change adds a onKeyDown handler for the input field, the handler listens for Enter
key press and calls the onConfirm callback, this change allows the user confirm the dialog
using the Enter key instead of pressing the Confirm button

Fixes #11177
  • Loading branch information
mhnaeem authored Oct 31, 2022
1 parent e0ade5c commit b4ad08c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions javascript/grid-ui/src/components/LiveView/PasswordDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ const PasswordDialog = (props) => {
event.preventDefault()
}

const handleKeyDown = (event: React.KeyboardEvent): void => {
if (event.key === 'Enter') {
event.preventDefault()
onConfirm(values.password)
}
};

return (
<Dialog
open={open}
Expand All @@ -86,6 +93,9 @@ const PasswordDialog = (props) => {
margin='dense'
type={values.showPassword ? 'text' : 'password'}
value={values.password}
inputProps={{
onKeyDown: handleKeyDown
}}
fullWidth
onChange={handleChange('password')}
endAdornment={
Expand Down

0 comments on commit b4ad08c

Please sign in to comment.