Scope the selection to the current view

A selection made in one workspace survived switching workspace or tab, so
the selection bar and its batch actions (copy, delete) kept acting on items
that were no longer visible. Switching workspace, switching tab, or closing
search now clears the selection.
This commit is contained in:
2026-10-24 20:20:43 +08:00
parent a75d6fdf41
commit e0c47ad010
2 changed files with 9 additions and 1 deletions
+7
View File
@@ -61,6 +61,11 @@ struct PanelView: View {
accessibilityGranted = AXIsProcessTrusted()
}
.onAppear { composerFocused = true }
// Selection is scoped to the current view: switching workspace, tab,
// or leaving search clears it. Otherwise a selection made in one
// workspace kept acting (copy, delete) on items you can no longer see.
.onChange(of: store.activeSectionID) { clearSelection() }
.onChange(of: tab) { clearSelection() }
}
// MARK: - Header
@@ -144,6 +149,7 @@ struct PanelView: View {
search = ""
showSearch = false
focusedField = nil
clearSelection()
composerFocused = true
}
if !search.isEmpty {
@@ -852,6 +858,7 @@ struct PanelView: View {
} else {
search = ""
focusedField = nil
clearSelection()
composerFocused = true
}
}