[grid] Add ability to use Enter key to confirm
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
@@ -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}
@@ -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={
