diff --git a/apps/admin-x-design-system/src/global/SortMenu.tsx b/apps/admin-x-design-system/src/global/SortMenu.tsx index 8677bef35e..cbaa218636 100644 --- a/apps/admin-x-design-system/src/global/SortMenu.tsx +++ b/apps/admin-x-design-system/src/global/SortMenu.tsx @@ -9,6 +9,7 @@ export type SortItem = { id: string, label: string; selected?: boolean; + direction?: SortDirection; } export interface SortMenuProps { @@ -31,7 +32,7 @@ const SortMenu: React.FC = ({ position = 'left' }) => { const [localItems, setLocalItems] = useState(items); - const [localDirection, setLocalDirection] = useState(direction || 'desc'); + const [localDirection, setLocalDirection] = useState(direction || 'desc'); useEffect(() => { setLocalItems(items); @@ -44,10 +45,16 @@ const SortMenu: React.FC = ({ })); setLocalItems(updatedItems); + if (localItems.find(item => item.id === selectedValue)?.direction) { + setLocalDirection(localItems.find(item => item.id === selectedValue)?.direction || 'desc'); + onDirectionChange(localDirection); + } + onSortChange(selectedValue); }; - const handleSortDirection = () => { + const handleSortDirection = (e?: React.MouseEvent) => { + e?.stopPropagation(); setLocalDirection(currentDirection => (currentDirection === 'desc' ? 'asc' : 'desc')); onDirectionChange(localDirection); }; diff --git a/apps/admin-x-settings/src/components/settings/growth/offers/OffersIndex.tsx b/apps/admin-x-settings/src/components/settings/growth/offers/OffersIndex.tsx index a72b202961..dd051c3470 100644 --- a/apps/admin-x-settings/src/components/settings/growth/offers/OffersIndex.tsx +++ b/apps/admin-x-settings/src/components/settings/growth/offers/OffersIndex.tsx @@ -294,9 +294,9 @@ export const OffersIndexModal = () => { {