Skip to content

Commit b4ad08c

Browse files
authored
[grid] Add ability to use Enter key to confirm (#11178)
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
1 parent e0ade5c commit b4ad08c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

javascript/grid-ui/src/components/LiveView/PasswordDialog.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ const PasswordDialog = (props) => {
6060
event.preventDefault()
6161
}
6262

63+
const handleKeyDown = (event: React.KeyboardEvent): void => {
64+
if (event.key === 'Enter') {
65+
event.preventDefault()
66+
onConfirm(values.password)
67+
}
68+
};
69+
6370
return (
6471
<Dialog
6572
open={open}
@@ -86,6 +93,9 @@ const PasswordDialog = (props) => {
8693
margin='dense'
8794
type={values.showPassword ? 'text' : 'password'}
8895
value={values.password}
96+
inputProps={{
97+
onKeyDown: handleKeyDown
98+
}}
8999
fullWidth
90100
onChange={handleChange('password')}
91101
endAdornment={

0 commit comments

Comments
 (0)