spot: fix event isolation from overlapping input events

This commit is contained in:
nick-delirium 2025-05-22 10:42:52 +02:00
parent e365b7b14f
commit 99b6238fc7
No known key found for this signature in database
GPG key ID: 93ABD695DF5FDBA0
2 changed files with 27 additions and 34 deletions

View file

@ -65,41 +65,34 @@ function SavingControls({
});
createEffect(() => {
const stopEvents = (e: Event) => {
e.stopPropagation();
e.stopImmediatePropagation();
};
if (nameInputRef) {
nameInputRef.addEventListener('keydown', stopEvents, true);
nameInputRef.addEventListener('keyup', stopEvents, true);
nameInputRef.addEventListener('keypress', stopEvents, true);
nameInputRef.addEventListener('input', stopEvents, true);
nameInputRef.addEventListener('change', stopEvents, true);
const stopEvents = (e: Event) => {
e.stopPropagation();
};
onCleanup(() => {
nameInputRef.removeEventListener('keydown', stopEvents, true);
nameInputRef.removeEventListener('keyup', stopEvents, true);
nameInputRef.removeEventListener('keypress', stopEvents, true);
nameInputRef.removeEventListener('input', stopEvents, true);
nameInputRef.removeEventListener('change', stopEvents, true);
});
}
if (descriptionInputRef) {
descriptionInputRef.addEventListener('keydown', stopEvents, true);
descriptionInputRef.addEventListener('keyup', stopEvents, true);
descriptionInputRef.addEventListener('keypress', stopEvents, true);
descriptionInputRef.addEventListener('input', stopEvents, true);
descriptionInputRef.addEventListener('change', stopEvents, true);
if (nameInputRef) {
nameInputRef.addEventListener('keydown', stopEvents);
nameInputRef.addEventListener('keyup', stopEvents);
nameInputRef.addEventListener('keypress',stopEvents);
onCleanup(() => {
descriptionInputRef.removeEventListener('keydown', stopEvents, true);
descriptionInputRef.removeEventListener('keyup', stopEvents, true);
descriptionInputRef.removeEventListener('keypress', stopEvents, true);
descriptionInputRef.removeEventListener('input', stopEvents, true);
descriptionInputRef.removeEventListener('change', stopEvents, true);
});
}
});
onCleanup(() => {
nameInputRef.removeEventListener('keydown', stopEvents);
nameInputRef.removeEventListener('keyup', stopEvents);
nameInputRef.removeEventListener('keypress',stopEvents);
});
}
if (descriptionInputRef) {
descriptionInputRef.addEventListener('keydown', stopEvents);
descriptionInputRef.addEventListener('keyup', stopEvents);
descriptionInputRef.addEventListener('keypress',stopEvents);
onCleanup(() => {
descriptionInputRef.removeEventListener('keydown', stopEvents);
descriptionInputRef.removeEventListener('keyup', stopEvents);
descriptionInputRef.removeEventListener('keypress',stopEvents);
});
}
});
const spacePressed = (e: KeyboardEvent) => {
if (

View file

@ -2,7 +2,7 @@
"name": "spot",
"description": "manifest.json description",
"private": true,
"version": "1.0.20",
"version": "1.0.21",
"type": "module",
"scripts": {
"dev": "wxt",