mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-09-11 22:51:05 +00:00
fix(web): clear document selection when the active space changes
The bulk-selection set (`selectedDocumentIds`) lived in AppExperience and was only cleared on explicit "clear", on successful bulk delete, or never. Switching spaces left the previous space's selected ids in the set while the grid rendered a different space, so the selection toolbar still showed them and "Delete selected" would permanently delete documents from another space that the user could no longer see. Clear the selection (and exit selection mode) whenever the active space changes. The functional updates return the previous reference when there is nothing to clear, so the initial mount doesn't cause needless re-renders.
This commit is contained in:
parent
5ecbc26345
commit
f641e3d3c0
1 changed files with 11 additions and 0 deletions
|
|
@ -294,6 +294,17 @@ export function AppExperience() {
|
|||
)
|
||||
const [isSelectionMode, setIsSelectionMode] = useState(false)
|
||||
|
||||
// Selection is scoped to the documents currently on screen. When the active
|
||||
// space changes the previous selection points at documents from another
|
||||
// space that are no longer visible, so clear it — otherwise "Delete selected"
|
||||
// would delete documents the user can't see anymore.
|
||||
const activeSpaceKey = selectedProjects.join("|")
|
||||
// biome-ignore lint/correctness/useExhaustiveDependencies: reset only when the space changes, not on selection edits
|
||||
useEffect(() => {
|
||||
setSelectedDocumentIds((prev) => (prev.size === 0 ? prev : new Set()))
|
||||
setIsSelectionMode((prev) => (prev ? false : prev))
|
||||
}, [activeSpaceKey])
|
||||
|
||||
const handleToggleSelection = useCallback((documentId: string) => {
|
||||
setSelectedDocumentIds((prev) => {
|
||||
const next = new Set(prev)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue