feat(ui): react upon enter key to create role

pull/5955/head
Pavel Zavora 2022-06-23 07:36:37 +02:00
parent 368ed615f5
commit 60cdebff5b
1 changed files with 10 additions and 0 deletions

View File

@ -25,6 +25,15 @@ const CreateRoleDialog = ({visible, setVisible, create}: Props) => {
setName('')
setVisible(false)
}, [])
const onEnterPressed = useCallback(
(e: React.KeyboardEvent<HTMLInputElement>) => {
if (e.key === 'Enter' && name) {
e.stopPropagation()
create({name})
}
},
[name, create]
)
return (
<OverlayTechnology visible={visible}>
<OverlayContainer maxWidth={650}>
@ -38,6 +47,7 @@ const CreateRoleDialog = ({visible, setVisible, create}: Props) => {
autoFocus={true}
autoComplete="off"
onChange={e => setName(e.target.value)}
onKeyPress={onEnterPressed}
status={
validateRoleName(name)
? ComponentStatus.Valid