Fix/library manga selection type error (#566)
* Prevent TypeError when deselecting items from a specific key This was noticed when changing the categories of a manga to a category without any selected mangas, in this case, when trying to deselect a manga after changing the categories, a TypeError was thrown which resulted in a white screen * Remove duplicates from the list of all selected ids * Update state via setter * Clear selection after disabling the library selection mode * Remove console log
This commit is contained in:
@@ -75,6 +75,7 @@ export function Library() {
|
||||
selectedItemIds,
|
||||
handleSelectAll,
|
||||
handleSelection,
|
||||
clearSelection,
|
||||
} = useSelectableCollection<TManga['id'], string>(mangas.length, { currentKey: activeTab?.id.toString() });
|
||||
|
||||
const handleSelect = (id: number, selected: boolean) => {
|
||||
@@ -108,6 +109,9 @@ export function Library() {
|
||||
onClose={(selectionModeState) => {
|
||||
handleClose();
|
||||
setIsSelectModeActive(selectionModeState);
|
||||
if (!selectionModeState) {
|
||||
clearSelection();
|
||||
}
|
||||
}}
|
||||
setHideMenu={setHideMenu}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user