fix(ui): make dashboardeditModal closable with esc
This commit is contained in:
parent
6a801a2026
commit
d4fa960fdf
1 changed files with 8 additions and 0 deletions
|
|
@ -18,6 +18,14 @@ function DashboardEditModal(props: Props) {
|
|||
dashboardStore.save(dashboard).then(closeHandler);
|
||||
}
|
||||
|
||||
React.useEffect(() => {
|
||||
const handleEsc = (e) => e.key === 'Escape' && closeHandler?.()
|
||||
document.addEventListener("keydown", handleEsc, false);
|
||||
return () => {
|
||||
document.removeEventListener("keydown", handleEsc, false);
|
||||
}
|
||||
}, [])
|
||||
|
||||
const write = ({ target: { value, name } }) => dashboard.update({ [ name ]: value })
|
||||
const writeOption = (e, { checked, name }) => {
|
||||
dashboard.update({ [name]: checked });
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue