diff --git a/resources/js/components/transactions/transaction-filters.tsx b/resources/js/components/transactions/transaction-filters.tsx index 15c8e69d..e4befaa7 100644 --- a/resources/js/components/transactions/transaction-filters.tsx +++ b/resources/js/components/transactions/transaction-filters.tsx @@ -420,12 +420,24 @@ function CategoryMultiSelect({ triggerClassName, }: CategoryMultiSelectProps) { const [open, setOpen] = useState(false); + // Snapshot the selected-first order when the dropdown opens so items don't + // reshuffle as the user toggles; it recomputes on the next open. + const [orderedCategories, setOrderedCategories] = useState(() => + sortSelectedFirst(categories, selectedIds), + ); const isUncategorizedSelected = selectedIds.includes( UNCATEGORIZED_CATEGORY_ID, ); + function handleOpenChange(next: boolean) { + if (next) { + setOrderedCategories(sortSelectedFirst(categories, selectedIds)); + } + setOpen(next); + } + return ( - +