fix(macos): preserve horizontal trackpad scrolling inside iframes

Copilot-Session: fddd7ed1-c260-45fb-9523-7117cdd5e772
Цей коміт міститься в:
Deng Liu committed 2026-11-25 09:26:01 -05:00
1 джерело 0b079af75d
коміт 39d5a62d92
2 files changed
+17 -1

No files matched your search

+14
Переглянути файл
@@ -127,4 +127,18 @@ describe("native page swipes", () => {
document.body.innerHTML = '<div class="xterm"><textarea></textarea></div>';
expect(ownsHorizontalScroll(document.querySelector("textarea"))).toBe(true);
});
it("leaves horizontal wheel handling to embedded iframes", () => {
vi.stubGlobal("__TAURI_INTERNALS__", {});
document.body.innerHTML = '<iframe sandbox="allow-scripts" title="Kubernetes"></iframe>';
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();
}
});
});
+3 -1
Переглянути файл
@@ -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;
}