diff --git a/packages/frontend/core/src/components/page-list/collections/virtualized-collection-list.tsx b/packages/frontend/core/src/components/page-list/collections/virtualized-collection-list.tsx index e1566cdd9a..32c0e9fe8b 100644 --- a/packages/frontend/core/src/components/page-list/collections/virtualized-collection-list.tsx +++ b/packages/frontend/core/src/components/page-list/collections/virtualized-collection-list.tsx @@ -98,8 +98,12 @@ export const VirtualizedCollectionList = ({ }, []); const handleDelete = useCallback(() => { - return collectionService.deleteCollection(info, ...selectedCollectionIds); - }, [collectionService, info, selectedCollectionIds]); + if (selectedCollectionIds.length === 0) { + return; + } + collectionService.deleteCollection(info, ...selectedCollectionIds); + hideFloatingToolbar(); + }, [collectionService, hideFloatingToolbar, info, selectedCollectionIds]); return ( <> @@ -123,7 +127,7 @@ export const VirtualizedCollectionList = ({ headerRenderer={collectionHeaderRenderer} /> 0} + open={showFloatingToolbar} content={ { + if (filteredSelectedPageIds.length === 0) { + return; + } const pageNameMapping = Object.fromEntries( pageMetas.map(meta => [meta.id, meta.title]) ); @@ -171,7 +174,7 @@ export const VirtualizedPageList = ({ headerRenderer={pageHeaderRenderer} /> 0} + open={showFloatingToolbar} onDelete={handleMultiDelete} onClose={hideFloatingToolbar} content={ diff --git a/packages/frontend/core/src/components/page-list/tags/virtualized-tag-list.tsx b/packages/frontend/core/src/components/page-list/tags/virtualized-tag-list.tsx index c8a71fa29b..1b56efee33 100644 --- a/packages/frontend/core/src/components/page-list/tags/virtualized-tag-list.tsx +++ b/packages/frontend/core/src/components/page-list/tags/virtualized-tag-list.tsx @@ -69,6 +69,9 @@ export const VirtualizedTagList = ({ }, []); const handleDelete = useCallback(() => { + if (selectedTagIds.length === 0) { + return; + } onTagDelete(selectedTagIds); hideFloatingToolbar(); return; @@ -97,7 +100,7 @@ export const VirtualizedTagList = ({ headerRenderer={tagHeaderRenderer} /> 0} + open={showFloatingToolbar} content={ { }, [filteredSelectedPageIds, hideFloatingToolbar, restoreFromTrash, t]); const onConfirmPermanentlyDelete = useCallback(() => { + if (filteredSelectedPageIds.length === 0) { + return; + } openConfirmModal({ title: `${t['com.affine.trashOperation.deletePermanently']()}?`, description: t['com.affine.trashOperation.deleteDescription'](), @@ -77,7 +80,7 @@ export const VirtualizedTrashList = () => { }, onConfirm: handleMultiDelete, }); - }, [handleMultiDelete, openConfirmModal, t]); + }, [filteredSelectedPageIds.length, handleMultiDelete, openConfirmModal, t]); const pageOperationsRenderer = useCallback( (item: ListItem) => { @@ -129,7 +132,7 @@ export const VirtualizedTrashList = () => { onSelectedIdsChange={setSelectedPageIds} /> 0} + open={showFloatingToolbar} onDelete={onConfirmPermanentlyDelete} onClose={hideFloatingToolbar} onRestore={handleMultiRestore}