mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-24 06:28:34 +01:00
feat: add support for create + add more for all create modals and support k… (#526)
* add support for create + add more for all create modals and support keyboard bindings
* listen for esc to close modals
Former-commit-id: 22bbaae08f
This commit is contained in:
@@ -32,6 +32,12 @@
|
||||
},
|
||||
});
|
||||
|
||||
function escClose(e: KeyboardEvent) {
|
||||
if (e.key === "Escape") {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
function close() {
|
||||
if (props.readonly) {
|
||||
emit("cancel");
|
||||
@@ -42,4 +48,12 @@
|
||||
|
||||
const modalId = useId();
|
||||
const modal = useVModel(props, "modelValue", emit);
|
||||
|
||||
watchEffect(() => {
|
||||
if (modal.value) {
|
||||
document.addEventListener("keydown", escClose);
|
||||
} else {
|
||||
document.removeEventListener("keydown", escClose);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user