Skip to content

Commit 706b8f2

Browse files
committed
fix: scrolling in Settings can switch the open note
A local scrollWheel monitor in SwipeDetectorView fired for every app window, not just the panel, so a horizontal scroll in Settings could trigger note navigation when the Settings window overlapped the panel. Gate on the event belonging to this view's window.
1 parent e757627 commit 706b8f2

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎EdgeMark/UI/Components/SwipeDetectorView.swift‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import OSLog
33
import SwiftUI
44

55
/// Transparent overlay that detects two-finger trackpad horizontal swipes
6-
/// via NSEvent scroll monitoring. Only fires when the cursor is inside this view's bounds.
7-
/// Mouse clicks pass through (hitTest returns nil).
6+
/// via NSEvent scroll monitoring. Only fires when the scroll belongs to this
7+
/// view's window and the cursor is inside its bounds. Mouse clicks pass through.
88
struct SwipeDetectorView: NSViewRepresentable {
99
var onSwipeBack: (() -> Void)?
1010
var onSwipeForward: (() -> Void)?
@@ -60,7 +60,12 @@ final class SwipeDetectorNSView: NSView {
6060
}
6161

6262
private func handleScroll(_ event: NSEvent) {
63-
guard window != nil else { return }
63+
// A local scrollWheel monitor fires for every app window, not just this one.
64+
// Ignore scrolls that belong to a different window (e.g. the Settings panel) —
65+
// otherwise a horizontal scroll in Settings can navigate the open note when the
66+
// Settings window overlaps the panel (event.locationInWindow is in the other
67+
// window's coordinate space, so the bounds check below is meaningless for it).
68+
guard let viewWindow = window, event.window === viewWindow else { return }
6469

6570
// Only respond to events where the cursor is inside this view (the header card)
6671
let locationInSelf = convert(event.locationInWindow, from: nil)

0 commit comments

Comments
 (0)