diff --git a/frontend/src/pages/destructionlist/abstract/BaseListView.tsx b/frontend/src/pages/destructionlist/abstract/BaseListView.tsx index 86200060..0de14dc8 100644 --- a/frontend/src/pages/destructionlist/abstract/BaseListView.tsx +++ b/frontend/src/pages/destructionlist/abstract/BaseListView.tsx @@ -144,23 +144,28 @@ export function BaseListView({ // Selection actions. const getSelectionActions = useCallback(() => { - const fixedItems = - selectable && hasSelection - ? ([ - { - children: ( - <> - - Huidige selectie wissen - - ), - variant: "warning", - wrap: false, - onClick: handleClearZaakSelection, - }, - ] as ButtonProps[]) - : []; - return [...(selectionActions || []), ...fixedItems]; + const disabled = selectable && hasSelection; + const dynamicItems = (selectionActions || []).map((props) => + Object.hasOwn(props, "disabled") + ? props + : { ...props, disabled: selectable && !hasSelection }, + ); + const fixedItems = disabled + ? ([ + { + children: ( + <> + + Huidige selectie wissen + + ), + variant: "warning", + wrap: false, + onClick: handleClearZaakSelection, + }, + ] as ButtonProps[]) + : []; + return [...dynamicItems, ...fixedItems]; }, [selectable, hasSelection, selectedZakenOnPage, selectionActions]); return ( diff --git a/frontend/src/pages/destructionlist/create/DestructionListCreate.tsx b/frontend/src/pages/destructionlist/create/DestructionListCreate.tsx index 28e60e4e..cadd6e3e 100644 --- a/frontend/src/pages/destructionlist/create/DestructionListCreate.tsx +++ b/frontend/src/pages/destructionlist/create/DestructionListCreate.tsx @@ -113,8 +113,6 @@ export function DestructionListCreatePage() { Vernietigingslijst opstellen ), - disabled: !allPagesSelected && !hasSelection, - variant: "primary", wrap: false, onClick: handleClick, diff --git a/frontend/src/pages/destructionlist/detail/components/DestructionListEdit/DestructionListEdit.tsx b/frontend/src/pages/destructionlist/detail/components/DestructionListEdit/DestructionListEdit.tsx index 87ee9bf9..73f3f6f9 100644 --- a/frontend/src/pages/destructionlist/detail/components/DestructionListEdit/DestructionListEdit.tsx +++ b/frontend/src/pages/destructionlist/detail/components/DestructionListEdit/DestructionListEdit.tsx @@ -109,6 +109,7 @@ export function DestructionListEdit() { Annuleren ), + disabled: false, // Set explicitly to prevent automatic value based on selection presence. wrap: false, onClick: () => handleSetEditing(false), }, diff --git a/frontend/src/pages/destructionlist/detail/components/DestructionListProcessReview/DestructionListProcessReview.tsx b/frontend/src/pages/destructionlist/detail/components/DestructionListProcessReview/DestructionListProcessReview.tsx index fcd93094..b11ce219 100644 --- a/frontend/src/pages/destructionlist/detail/components/DestructionListProcessReview/DestructionListProcessReview.tsx +++ b/frontend/src/pages/destructionlist/detail/components/DestructionListProcessReview/DestructionListProcessReview.tsx @@ -142,9 +142,6 @@ export function DestructionListProcessReview() { }; }, [reviewItems, objectList]); - // Selection actions based on `editingState`. - const selectionActions: ButtonProps[] = useMemo(() => [], []); - /** * Gets called when te selection is cleared. */ @@ -227,7 +224,6 @@ export function DestructionListProcessReview() { paginatedZaken={paginatedZaken} secondaryNavigationItems={secondaryNavigationItems} selectable="visible" - selectionActions={selectionActions} storageKey={storageKey} onClearZaakSelection={handleClearSelection} > diff --git a/frontend/src/pages/destructionlist/hooks/useZaakSelection.ts b/frontend/src/pages/destructionlist/hooks/useZaakSelection.ts index 299e38ea..5690ffe8 100644 --- a/frontend/src/pages/destructionlist/hooks/useZaakSelection.ts +++ b/frontend/src/pages/destructionlist/hooks/useZaakSelection.ts @@ -5,7 +5,6 @@ import { ZaakSelection, addToZaakSelection, getAllZakenSelected, - getFilteredZaakSelection, getZaakSelectionItem, getZaakSelectionSize, clearZaakSelection as libClearZaakSelection, @@ -63,9 +62,6 @@ export function useZaakSelection( // All pages selected. const [allPagesSelectedState, setAllPagesSelectedState] = useState(); - // Has selection items. - const [hasSelectionState, setHasSelectionState] = useState(); - // Selection count const [selectionSizeState, setSelectionSizeState] = useState(0); @@ -82,13 +78,6 @@ export function useZaakSelection( } }); - getFilteredZaakSelection(storageKey).then((zs) => { - const hasSelection = Object.keys(zs).length > 0; - if (hasSelection !== hasSelectionState) { - setHasSelectionState(hasSelection); - } - }); - getZaakSelectionSize(storageKey).then((size) => { if (size !== selectionSizeState) { setSelectionSizeState(size); @@ -281,7 +270,7 @@ export function useZaakSelection( selectedZakenOnPage, onSelect, { - hasSelection: Boolean(hasSelectionState || allPagesSelectedState), + hasSelection: Boolean(selectionSizeState || allPagesSelectedState), allPagesSelected: Boolean(allPagesSelectedState), selectionSize: selectionSizeState, deSelectedZakenOnPage,