From adb757aa036aae8b35091e9fd4ba04b064001b3c Mon Sep 17 00:00:00 2001 From: Yauheni Mileika Date: Thu, 5 Dec 2024 12:26:10 +0300 Subject: [PATCH] feat(AsideHeader): add sort callback for AsideHeader --- src/components/AllPagesPanel/AllPagesPanel.tsx | 1 + .../AsideHeader/__stories__/AsideHeaderShowcase.tsx | 4 +++- src/components/AsideHeader/types.tsx | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/AllPagesPanel/AllPagesPanel.tsx b/src/components/AllPagesPanel/AllPagesPanel.tsx index 984fefd..c993cb9 100644 --- a/src/components/AllPagesPanel/AllPagesPanel.tsx +++ b/src/components/AllPagesPanel/AllPagesPanel.tsx @@ -106,6 +106,7 @@ export const AllPagesPanel: React.FC = (props) => { newItems.splice(newIndex, 0, element); onMenuItemsChanged?.(newItems); + editMenuProps?.onChangeItemsOrder?.(element, oldIndex, newIndex); }, [onMenuItemsChanged], ); diff --git a/src/components/AsideHeader/__stories__/AsideHeaderShowcase.tsx b/src/components/AsideHeader/__stories__/AsideHeaderShowcase.tsx index 7fa5c9f..7ea5513 100644 --- a/src/components/AsideHeader/__stories__/AsideHeaderShowcase.tsx +++ b/src/components/AsideHeader/__stories__/AsideHeaderShowcase.tsx @@ -297,7 +297,9 @@ export const AsideHeaderShowcase: React.FC = ({ }} onMenuMoreClick={() => console.log('onMenuMoreClick')} onAllPagesClick={() => console.log('onAllPagesClick')} - editMenuProps={{enableSorting: true}} + editMenuProps={{ + enableSorting: true, + }} /> ); diff --git a/src/components/AsideHeader/types.tsx b/src/components/AsideHeader/types.tsx index 55f82d1..a38d84f 100644 --- a/src/components/AsideHeader/types.tsx +++ b/src/components/AsideHeader/types.tsx @@ -23,6 +23,7 @@ export interface EditMenuProps { onToggleMenuItem?: (changedItem: MenuItem) => void; onResetSettingsToDefault?: () => void; enableSorting?: boolean; + onChangeItemsOrder?: (changedItem: MenuItem, oldIndex: number, newIndex: number) => void; } export interface AsideHeaderGeneralProps extends QAProps {