From 02992cff596ef9a159df27eac4a3b37ecdcd9892 Mon Sep 17 00:00:00 2001 From: typhonrt Date: Sun, 1 Dec 2024 13:02:00 -0800 Subject: [PATCH] Fix bring to top pointer down with `capture` on app element. --- .../component/application/ApplicationShell.svelte | 7 +++++-- .../application/EmptyApplicationShell.svelte | 15 +++++++++++++-- .../application/TJSApplicationShell.svelte | 7 +++++-- src/component/application/ApplicationShell.svelte | 7 +++++-- .../application/EmptyApplicationShell.svelte | 15 +++++++++++++-- .../application/TJSApplicationShell.svelte | 7 +++++-- 6 files changed, 46 insertions(+), 12 deletions(-) diff --git a/_dist/component/application/ApplicationShell.svelte b/_dist/component/application/ApplicationShell.svelte index d01fd57..e38dcbb 100644 --- a/_dist/component/application/ApplicationShell.svelte +++ b/_dist/component/application/ApplicationShell.svelte @@ -292,6 +292,9 @@ /** * If the application is a popOut application then when clicked bring to top if not already the Foundry * `activeWindow`. + * + * Note: `capture` is used so pointer down is always received. Be mindful as `onPointerdownApp` should only + * invoke `bringToTop`. */ function onPointerdownApp() { @@ -398,7 +401,7 @@ out:outTransition|global={outTransitionOptions} on:close:popup|preventDefault|stopPropagation={onClosePopup} on:keydown={onKeydown} - on:pointerdown={onPointerdownApp} + on:pointerdown|capture={onPointerdownApp} use:applyStyles={stylesApp} use:dynamicAction={appResizeObserver} role=application @@ -423,7 +426,7 @@ bind:this={elementRoot} on:close:popup|preventDefault|stopPropagation={onClosePopup} on:keydown={onKeydown} - on:pointerdown={onPointerdownApp} + on:pointerdown|capture={onPointerdownApp} use:applyStyles={stylesApp} use:dynamicAction={appResizeObserver} role=application diff --git a/_dist/component/application/EmptyApplicationShell.svelte b/_dist/component/application/EmptyApplicationShell.svelte index c856d4a..a9886b5 100644 --- a/_dist/component/application/EmptyApplicationShell.svelte +++ b/_dist/component/application/EmptyApplicationShell.svelte @@ -269,8 +269,7 @@ } /** - * If the application is a popOut application then when clicked bring to top if not already the Foundry - * `activeWindow`. + * Handle focus management on any pointer events, `non-capture`. * * @param {PointerEvent} event - A PointerEvent. */ @@ -302,7 +301,17 @@ elementRoot.focus(); } } + } + /** + * If the application is a popOut application then when clicked bring to top if not already the Foundry + * `activeWindow`. + * + * Note: `capture` is used so pointer down is always received. Be mindful as `onPointerdownAppTopMost` should only + * invoke `bringToTop`. + */ + function onPointerdownAppTopMost() + { if (typeof application?.options?.popOut === 'boolean' && application.options.popOut && application !== globalThis.ui?.activeWindow) { @@ -356,6 +365,7 @@ out:outTransition|global={outTransitionOptions} on:close:popup|preventDefault|stopPropagation={onClosePopup} on:keydown={onKeydown} + on:pointerdown|capture={onPointerdownAppTopMost} on:pointerdown={onPointerdownApp} use:applyStyles={stylesApp} use:dynamicAction={appResizeObserver} @@ -373,6 +383,7 @@ bind:this={elementRoot} on:close:popup|preventDefault|stopPropagation={onClosePopup} on:keydown={onKeydown} + on:pointerdown|capture={onPointerdownAppTopMost} on:pointerdown={onPointerdownApp} use:applyStyles={stylesApp} use:dynamicAction={appResizeObserver} diff --git a/_dist/component/application/TJSApplicationShell.svelte b/_dist/component/application/TJSApplicationShell.svelte index 0a3c1e9..10175cc 100644 --- a/_dist/component/application/TJSApplicationShell.svelte +++ b/_dist/component/application/TJSApplicationShell.svelte @@ -298,6 +298,9 @@ /** * If the application is a popOut application then when clicked bring to top if not already the Foundry * `activeWindow`. + * + * Note: `capture` is used so pointer down is always received. Be mindful as `onPointerdownApp` should only + * invoke `bringToTop`. */ function onPointerdownApp() { @@ -404,7 +407,7 @@ out:outTransition|global={outTransitionOptions} on:close:popup|preventDefault|stopPropagation={onClosePopup} on:keydown={onKeydown} - on:pointerdown={onPointerdownApp} + on:pointerdown|capture={onPointerdownApp} use:applyStyles={stylesApp} use:dynamicAction={appResizeObserver} role=application @@ -429,7 +432,7 @@ bind:this={elementRoot} on:close:popup|preventDefault|stopPropagation={onClosePopup} on:keydown={onKeydown} - on:pointerdown={onPointerdownApp} + on:pointerdown|capture={onPointerdownApp} use:applyStyles={stylesApp} use:dynamicAction={appResizeObserver} role=application diff --git a/src/component/application/ApplicationShell.svelte b/src/component/application/ApplicationShell.svelte index 2b1ff3c..3e59666 100644 --- a/src/component/application/ApplicationShell.svelte +++ b/src/component/application/ApplicationShell.svelte @@ -292,6 +292,9 @@ /** * If the application is a popOut application then when clicked bring to top if not already the Foundry * `activeWindow`. + * + * Note: `capture` is used so pointer down is always received. Be mindful as `onPointerdownApp` should only + * invoke `bringToTop`. */ function onPointerdownApp() { @@ -398,7 +401,7 @@ out:outTransition|global={outTransitionOptions} on:close:popup|preventDefault|stopPropagation={onClosePopup} on:keydown={onKeydown} - on:pointerdown={onPointerdownApp} + on:pointerdown|capture={onPointerdownApp} use:applyStyles={stylesApp} use:dynamicAction={appResizeObserver} role=application @@ -423,7 +426,7 @@ bind:this={elementRoot} on:close:popup|preventDefault|stopPropagation={onClosePopup} on:keydown={onKeydown} - on:pointerdown={onPointerdownApp} + on:pointerdown|capture={onPointerdownApp} use:applyStyles={stylesApp} use:dynamicAction={appResizeObserver} role=application diff --git a/src/component/application/EmptyApplicationShell.svelte b/src/component/application/EmptyApplicationShell.svelte index 170183f..d430d90 100644 --- a/src/component/application/EmptyApplicationShell.svelte +++ b/src/component/application/EmptyApplicationShell.svelte @@ -269,8 +269,7 @@ } /** - * If the application is a popOut application then when clicked bring to top if not already the Foundry - * `activeWindow`. + * Handle focus management on any pointer events, `non-capture`. * * @param {PointerEvent} event - A PointerEvent. */ @@ -302,7 +301,17 @@ elementRoot.focus(); } } + } + /** + * If the application is a popOut application then when clicked bring to top if not already the Foundry + * `activeWindow`. + * + * Note: `capture` is used so pointer down is always received. Be mindful as `onPointerdownAppTopMost` should only + * invoke `bringToTop`. + */ + function onPointerdownAppTopMost() + { if (typeof application?.options?.popOut === 'boolean' && application.options.popOut && application !== globalThis.ui?.activeWindow) { @@ -356,6 +365,7 @@ out:outTransition|global={outTransitionOptions} on:close:popup|preventDefault|stopPropagation={onClosePopup} on:keydown={onKeydown} + on:pointerdown|capture={onPointerdownAppTopMost} on:pointerdown={onPointerdownApp} use:applyStyles={stylesApp} use:dynamicAction={appResizeObserver} @@ -373,6 +383,7 @@ bind:this={elementRoot} on:close:popup|preventDefault|stopPropagation={onClosePopup} on:keydown={onKeydown} + on:pointerdown|capture={onPointerdownAppTopMost} on:pointerdown={onPointerdownApp} use:applyStyles={stylesApp} use:dynamicAction={appResizeObserver} diff --git a/src/component/application/TJSApplicationShell.svelte b/src/component/application/TJSApplicationShell.svelte index a0eba7c..af67b4e 100644 --- a/src/component/application/TJSApplicationShell.svelte +++ b/src/component/application/TJSApplicationShell.svelte @@ -298,6 +298,9 @@ /** * If the application is a popOut application then when clicked bring to top if not already the Foundry * `activeWindow`. + * + * Note: `capture` is used so pointer down is always received. Be mindful as `onPointerdownApp` should only + * invoke `bringToTop`. */ function onPointerdownApp() { @@ -404,7 +407,7 @@ out:outTransition|global={outTransitionOptions} on:close:popup|preventDefault|stopPropagation={onClosePopup} on:keydown={onKeydown} - on:pointerdown={onPointerdownApp} + on:pointerdown|capture={onPointerdownApp} use:applyStyles={stylesApp} use:dynamicAction={appResizeObserver} role=application @@ -429,7 +432,7 @@ bind:this={elementRoot} on:close:popup|preventDefault|stopPropagation={onClosePopup} on:keydown={onKeydown} - on:pointerdown={onPointerdownApp} + on:pointerdown|capture={onPointerdownApp} use:applyStyles={stylesApp} use:dynamicAction={appResizeObserver} role=application