Skip to content

High performance self-hosted photo and video management solution.

fix(web): don't swallow Escape when person name editor is closed (#32123)

Adi Čaušević3a5fc38f85df
diff --git a/web/src/lib/actions/click-outside.ts b/web/src/lib/actions/click-outside.ts
index af4ec86956..292e28e71c 100644
--- a/web/src/lib/actions/click-outside.ts
+++ b/web/src/lib/actions/click-outside.ts
@@ -12,10 +12,9 @@ interface Options {
* @param options Object containing onOutclick and onEscape functions
* @returns
*/
-export function clickOutside(node: HTMLElement, options: Options = {}): ActionReturn {
- const { onOutclick, onEscape } = options;
-
+export function clickOutside(node: HTMLElement, options: Options = {}): ActionReturn<Options> {
const handleClick = (event: MouseEvent) => {
+ const { onOutclick } = options;
const targetNode = event.target as Node | null;
if (node.contains(targetNode)) {
return;
@@ -25,6 +24,7 @@ export function clickOutside(node: HTMLElement, options: Options = {}): ActionRe
};
const handleKey = (event: KeyboardEvent) => {
+ const { onEscape } = options;
if (!matchesShortcut(event, { key: 'Escape' })) {
return;
}
@@ -39,6 +39,9 @@ export function clickOutside(node: HTMLElement, options: Options = {}): ActionRe
node.addEventListener('keydown', handleKey, { capture: false });
return {
+ update(newOptions: Options) {
+ options = newOptions;
+ },
destroy() {
document.removeEventListener('mousedown', handleClick, false);
node.removeEventListener('keydown', handleKey, false);
diff --git a/web/src/routes/(user)/people/[personId]/[[photos=photos]]/[[assetId=id]]/+page.svelte b/web/src/routes/(user)/people/[personId]/[[photos=photos]]/[[assetId=id]]/+page.svelte
index 347f4be046..ab749a45ac 100644
--- a/web/src/routes/(user)/people/[personId]/[[photos=photos]]/[[assetId=id]]/+page.svelte
+++ b/web/src/routes/(user)/people/[personId]/[[photos=photos]]/[[assetId=id]]/+page.svelte
@@ -362,7 +362,7 @@
class="relative w-fit p-4 pt-12 sm:px-6"
use:clickOutside={{
onOutclick: handleCancelEditName,
- onEscape: handleCancelEditName,
+ onEscape: isEditingName ? handleCancelEditName : undefined,
}}
use:listNavigation={suggestionContainer}
>