Skip to content

Commit dc6715e

Browse files
fix(web): swipe navigation keeps main's gesture-end handling
Ignoring wheels until the next native scroll-begin dropped the first wheel of a gesture whose begin arrives late and disabled swipes over canvases that cancel wheel events. The reported bug is fixed by the tab strip change alone, so this restores main's handling. AI-assisted; verified with the tests and tools listed above. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent e628689 commit dc6715e

2 files changed

Lines changed: 6 additions & 14 deletions

File tree

‎apps/web/src/components/HistorySwipeNavigation.tsx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export function HistorySwipeNavigation() {
9696
useEffect(() => {
9797
let gesture: SwipeGesture | null = null;
9898
const hideIndicator = () =>
99-
setSwipe((current) => (current?.tracking ? { ...current, tracking: false } : current));
99+
setSwipe((current) => (current === null ? null : { ...current, tracking: false }));
100100
// The fingers lifted: navigate if the swipe went far enough, then ignore its momentum.
101101
const release = () => {
102102
if (gesture?.kind === "tracking" && gesture.distance >= SWIPE_TRIGGER_DISTANCE) {
@@ -109,8 +109,10 @@ export function HistorySwipeNavigation() {
109109
const unsubscribeScrollBegin = window.desktopBridge?.onTrackpadScrollBegin(() => {
110110
if (gesture?.kind === "ignored") gesture = null;
111111
});
112-
// A gesture's last wheels can arrive after its end IPC; ignore them until the next begin.
113-
const unsubscribeScrollEnd = window.desktopBridge?.onTrackpadScrollEnd(release);
112+
const unsubscribeScrollEnd = window.desktopBridge?.onTrackpadScrollEnd(() => {
113+
if (gesture?.kind === "tracking") release();
114+
gesture = null;
115+
});
114116
const onWheel = (event: WheelEvent) => {
115117
if (gesture === null) {
116118
gesture =

‎apps/web/src/components/RightPanelTabs.browser.test.tsx‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import "~/index.css";
33
import { describe, expect, it, vi } from "vite-plus/test";
44

55
import type { RightPanelSurface } from "~/rightPanelStore";
6-
import { act, render, stubGlobal } from "../../test/render";
6+
import { render, stubGlobal } from "../../test/render";
77
import { HistorySwipeNavigation } from "./HistorySwipeNavigation";
88
import { RightPanelTabs } from "./RightPanelTabs";
99

@@ -127,16 +127,6 @@ describe("RightPanelTabs", () => {
127127
expect(viewport.scrollLeft).toBe(0);
128128
expect(navigateHistory).not.toHaveBeenCalled();
129129

130-
// Gesture events reach the renderer over IPC, so a wheel can land after its gesture's end.
131-
await act(() => {
132-
viewport.dispatchEvent(new WheelEvent("wheel", { deltaX: -10, bubbles: true }));
133-
});
134-
expect(screen.container.querySelector(".lucide-arrow-left")).toBeNull();
135-
viewport.scrollLeft = 120;
136-
scroll(viewport.querySelector("[data-active-tab]")!, [-10, -20, -30, ...momentum]);
137-
138-
expect(navigateHistory).not.toHaveBeenCalled();
139-
140130
viewport.scrollLeft = 0;
141131
scroll(viewport.querySelector("[data-active-tab]")!, [-40, -40, -40, -40, -40]);
142132

0 commit comments

Comments
 (0)