feat: add keyboard shortcuts support for dialog confirmation (#15752)
This commit is contained in:
parent
49c952a631
commit
e796937d02
@ -46,13 +46,17 @@ function Confirm({
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.key === 'Escape')
|
||||
onCancel()
|
||||
if (event.key === 'Enter' && isShow) {
|
||||
event.preventDefault()
|
||||
onConfirm()
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('keydown', handleKeyDown)
|
||||
return () => {
|
||||
document.removeEventListener('keydown', handleKeyDown)
|
||||
}
|
||||
}, [onCancel])
|
||||
}, [onCancel, onConfirm, isShow])
|
||||
|
||||
const handleClickOutside = (event: MouseEvent) => {
|
||||
if (maskClosable && dialogRef.current && !dialogRef.current.contains(event.target as Node))
|
||||
|
Loading…
Reference in New Issue
Block a user