feat: ESC zamyka wszystkie modale (Custom Game, Simulation, Win)

This commit is contained in:
2026-02-12 13:51:10 +01:00
parent 82a3717689
commit 57ae54d716
2 changed files with 27 additions and 1 deletions

View File

@@ -156,6 +156,7 @@ const stopDrag = () => {
onUnmounted(() => {
window.removeEventListener('mousemove', onDrag);
window.removeEventListener('mouseup', stopDrag);
window.removeEventListener('keydown', onKeyDown);
});
const showAdvanced = ref(false);
@@ -169,6 +170,16 @@ const toggleAdvanced = () => {
}
};
const handleClose = () => {
emit('close');
};
const onKeyDown = (e) => {
if (e.key === 'Escape') {
handleClose();
}
};
onMounted(() => {
const savedSize = localStorage.getItem('nonograms_custom_size');
if (savedSize && !isNaN(savedSize)) {
@@ -181,6 +192,7 @@ onMounted(() => {
}
// Don't draw map initially if hidden
window.addEventListener('keydown', onKeyDown);
});
watch([customSize, fillRate], () => {