fix(core): listFloatingToolbar does not appear as expected (#7124)

close AFF-1201
This commit is contained in:
JimmFly 2024-05-31 10:16:41 +00:00
parent 1b633b5135
commit b65c01c5e1
No known key found for this signature in database
GPG Key ID: 14A6F56854E1BED7
4 changed files with 20 additions and 7 deletions

View File

@ -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}
/>
<ListFloatingToolbar
open={showFloatingToolbar && selectedCollectionIds.length > 0}
open={showFloatingToolbar}
content={
<Trans
i18nKey="com.affine.collection.toolbar.selected"

View File

@ -132,6 +132,9 @@ export const VirtualizedPageList = ({
const { setTrashModal } = useTrashModalHelper(currentWorkspace.docCollection);
const handleMultiDelete = useCallback(() => {
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}
/>
<ListFloatingToolbar
open={showFloatingToolbar && filteredSelectedPageIds.length > 0}
open={showFloatingToolbar}
onDelete={handleMultiDelete}
onClose={hideFloatingToolbar}
content={

View File

@ -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}
/>
<ListFloatingToolbar
open={showFloatingToolbar && selectedTagIds.length > 0}
open={showFloatingToolbar}
content={
<Trans
i18nKey="com.affine.tag.toolbar.selected"

View File

@ -67,6 +67,9 @@ export const VirtualizedTrashList = () => {
}, [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}
/>
<ListFloatingToolbar
open={showFloatingToolbar && filteredSelectedPageIds.length > 0}
open={showFloatingToolbar}
onDelete={onConfirmPermanentlyDelete}
onClose={hideFloatingToolbar}
onRestore={handleMultiRestore}