From 39d5a62d9298cae97b693ea490f7bfdda67babfe Mon Sep 17 00:00:00 2001 From: Deng Liu Date: Wed, 25 Nov 2026 09:26:01 -0500 Subject: [PATCH] fix(macos): preserve horizontal trackpad scrolling inside iframes Copilot-Session: fddd7ed1-c260-45fb-9523-7117cdd5e772 --- src/platform/pageSwipe.test.ts | 14 ++++++++++++++ src/platform/pageSwipe.ts | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/platform/pageSwipe.test.ts b/src/platform/pageSwipe.test.ts index 7572d373a..9dff96ef6 100644 --- a/src/platform/pageSwipe.test.ts +++ b/src/platform/pageSwipe.test.ts @@ -127,4 +127,18 @@ describe("native page swipes", () => { document.body.innerHTML = '
'; expect(ownsHorizontalScroll(document.querySelector("textarea"))).toBe(true); }); + it("leaves horizontal wheel handling to embedded iframes", () => { + vi.stubGlobal("__TAURI_INTERNALS__", {}); + document.body.innerHTML = ''; + const iframe = document.querySelector("iframe")!; + expect(ownsHorizontalScroll(iframe)).toBe(true); + Object.defineProperty(document, "elementFromPoint", { configurable: true, value: () => iframe }); + const stop = installPageSwipeTracking(window); + try { + window.dispatchEvent(new CustomEvent("ide:page-swipe-candidate", { detail: { id: 99, x: 10, y: 20 } })); + expect(emitTo).not.toHaveBeenCalled(); + } finally { + stop(); + } + }); }); diff --git a/src/platform/pageSwipe.ts b/src/platform/pageSwipe.ts index 2734c5ddd..633c2c469 100644 --- a/src/platform/pageSwipe.ts +++ b/src/platform/pageSwipe.ts @@ -13,7 +13,9 @@ export function isPageSwipe(stroke: unknown): stroke is PageSwipe { export function ownsHorizontalScroll(element: Element | null): boolean { for (let el = element; el; el = el.parentElement) { // Terminal applications consume wheel events themselves (including alternate-screen apps). - if (el.classList.contains("xterm") || el.hasAttribute("data-wheel-scroll")) return true; + // Embedded iframes (plugin web views, previews, DevTools) may be opaque or cross-origin, so + // the host cannot inspect whether content inside them scrolls horizontally. + if (el.tagName === "IFRAME" || el.classList.contains("xterm") || el.hasAttribute("data-wheel-scroll")) return true; const overflow = getComputedStyle(el).overflowX; if (el.scrollWidth > el.clientWidth && /^(auto|scroll|overlay)$/.test(overflow)) return true; }