Clear selection after performing action
After an action the selected chapters might get hidden due to active filters.
Same as fde33a2412, don't want to bother dealing with this.
This commit is contained in:
@@ -75,14 +75,24 @@ const StyledVirtuoso = styled(Virtuoso, {
|
|||||||
const ChapterListFAB = ({
|
const ChapterListFAB = ({
|
||||||
selectedChapters,
|
selectedChapters,
|
||||||
firstUnreadChapter,
|
firstUnreadChapter,
|
||||||
|
onFABMenuClose,
|
||||||
}: {
|
}: {
|
||||||
selectedChapters: ChapterListFieldsFragment[];
|
selectedChapters: ChapterListFieldsFragment[];
|
||||||
firstUnreadChapter: ComponentProps<typeof ResumeFab>['chapter'] | null | undefined;
|
firstUnreadChapter: ComponentProps<typeof ResumeFab>['chapter'] | null | undefined;
|
||||||
|
onFABMenuClose?: () => void;
|
||||||
}) => {
|
}) => {
|
||||||
if (selectedChapters.length) {
|
if (selectedChapters.length) {
|
||||||
return (
|
return (
|
||||||
<SelectionFAB selectedItemsCount={selectedChapters.length} title="chapter.title_one">
|
<SelectionFAB selectedItemsCount={selectedChapters.length} title="chapter.title_one">
|
||||||
{(handleClose) => <ChapterActionMenuItems selectedChapters={selectedChapters} onClose={handleClose} />}
|
{(handleClose) => (
|
||||||
|
<ChapterActionMenuItems
|
||||||
|
selectedChapters={selectedChapters}
|
||||||
|
onClose={() => {
|
||||||
|
onFABMenuClose?.();
|
||||||
|
handleClose();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</SelectionFAB>
|
</SelectionFAB>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -139,8 +149,14 @@ export const ChapterList = ({
|
|||||||
const noChaptersFound = chapters.length === 0;
|
const noChaptersFound = chapters.length === 0;
|
||||||
const noChaptersMatchingFilter = !noChaptersFound && visibleChapters.length === 0;
|
const noChaptersMatchingFilter = !noChaptersFound && visibleChapters.length === 0;
|
||||||
|
|
||||||
const { areNoItemsSelected, areAllItemsSelected, selectedItemIds, handleSelectAll, handleSelection } =
|
const {
|
||||||
useSelectableCollection(visibleChapterIds.length, { itemIds: visibleChapterIds, currentKey: 'default' });
|
areNoItemsSelected,
|
||||||
|
areAllItemsSelected,
|
||||||
|
selectedItemIds,
|
||||||
|
handleSelectAll,
|
||||||
|
handleSelection,
|
||||||
|
clearSelection,
|
||||||
|
} = useSelectableCollection(visibleChapterIds.length, { itemIds: visibleChapterIds, currentKey: 'default' });
|
||||||
|
|
||||||
const onSelect = useCallback(
|
const onSelect = useCallback(
|
||||||
(id: number, selected: boolean, selectRange?: boolean) => handleSelection(id, selected, { selectRange }),
|
(id: number, selected: boolean, selectRange?: boolean) => handleSelection(id, selected, { selectRange }),
|
||||||
@@ -233,6 +249,7 @@ export const ChapterList = ({
|
|||||||
.map((id) => chapters.find((chapter) => chapter.id === id))
|
.map((id) => chapters.find((chapter) => chapter.id === id))
|
||||||
.filter((chapter) => chapter != null)}
|
.filter((chapter) => chapter != null)}
|
||||||
firstUnreadChapter={manga.firstUnreadChapter}
|
firstUnreadChapter={manga.firstUnreadChapter}
|
||||||
|
onFABMenuClose={clearSelection}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user