fix: priorytet ESC i zatrzymanie propagacji w modalach
This commit is contained in:
17
src/App.vue
17
src/App.vue
@@ -28,6 +28,21 @@ const appVersion = __APP_VERSION__;
|
||||
let displayModeMedia = null;
|
||||
let prefersColorSchemeMedia = null;
|
||||
|
||||
const onKeyDownGlobal = (e) => {
|
||||
if (e.key !== 'Escape') return;
|
||||
if (showSimulation.value) {
|
||||
showSimulation.value = false;
|
||||
return;
|
||||
}
|
||||
if (showCustomModal.value) {
|
||||
showCustomModal.value = false;
|
||||
return;
|
||||
}
|
||||
if (store.isGameWon) {
|
||||
store.closeWinModal();
|
||||
}
|
||||
};
|
||||
|
||||
const installLabel = computed(() => {
|
||||
return isCoarsePointer.value ? t('pwa.installMobile') : t('pwa.installDesktop');
|
||||
});
|
||||
@@ -114,6 +129,7 @@ onMounted(() => {
|
||||
} else if (displayModeMedia?.addListener) {
|
||||
displayModeMedia.addListener(updateStandalone);
|
||||
}
|
||||
window.addEventListener('keydown', onKeyDownGlobal);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -131,6 +147,7 @@ onUnmounted(() => {
|
||||
} else if (displayModeMedia?.removeListener) {
|
||||
displayModeMedia.removeListener(updateStandalone);
|
||||
}
|
||||
window.removeEventListener('keydown', onKeyDownGlobal);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -156,7 +156,6 @@ const stopDrag = () => {
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('mousemove', onDrag);
|
||||
window.removeEventListener('mouseup', stopDrag);
|
||||
window.removeEventListener('keydown', onKeyDown);
|
||||
});
|
||||
|
||||
const showAdvanced = ref(false);
|
||||
@@ -170,16 +169,6 @@ 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)) {
|
||||
@@ -192,7 +181,6 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
// Don't draw map initially if hidden
|
||||
window.addEventListener('keydown', onKeyDown);
|
||||
});
|
||||
|
||||
watch([customSize, fillRate], () => {
|
||||
|
||||
@@ -23,6 +23,8 @@ let stopRequested = false;
|
||||
|
||||
const onKeyDown = (e) => {
|
||||
if (e.key === 'Escape') {
|
||||
e.stopImmediatePropagation?.();
|
||||
e.preventDefault?.();
|
||||
emit('close');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -28,6 +28,8 @@ const handleClose = () => {
|
||||
|
||||
const handleKeyDown = (e) => {
|
||||
if (e.key === 'Escape') {
|
||||
e.stopImmediatePropagation?.();
|
||||
e.preventDefault?.();
|
||||
handleClose();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user