Skip to content

Commit

Permalink
fix: fix highlighted item in story
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunory committed Sep 8, 2023
1 parent 7d9a989 commit f077aad
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/components/AsideHeader/__stories__/AsideHeaderShowcase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,6 @@ interface AsideHeaderShowcaseProps {
initialCompact?: boolean;
}

const openModalSubscriber = (callback: OpenModalSubscriber) => {
// @ts-ignore
eventBroker.subscribe((data: EventBrokerData<{layersCount: number}>) => {
if (data?.eventId === 'layerschange') {
callback(data?.meta?.layersCount !== 0);
}
});
};

export const AsideHeaderShowcase: FC<AsideHeaderShowcaseProps> = ({
multipleTooltip = false,
initialCompact = false,
Expand All @@ -53,6 +44,17 @@ export const AsideHeaderShowcase: FC<AsideHeaderShowcaseProps> = ({

const navRef = React.useRef<AsideHeader>(null);

const openModalSubscriber = (callback: OpenModalSubscriber) => {
// @ts-ignore
eventBroker.subscribe((data: EventBrokerData<{layersCount: number}>) => {
if (!isModalOpen) {
callback(false);

Check warning on line 51 in src/components/AsideHeader/__stories__/AsideHeaderShowcase.tsx

View workflow job for this annotation

GitHub Actions / Verify Files

Expected return with your callback function
} else if (data?.eventId === 'layerschange') {
callback(data?.meta?.layersCount !== 0);

Check warning on line 53 in src/components/AsideHeader/__stories__/AsideHeaderShowcase.tsx

View workflow job for this annotation

GitHub Actions / Verify Files

Expected return with your callback function
}
});
};

return (
<div className={b()}>
<Modal open={isModalOpen} onClose={() => setIsModalOpen(false)}>
Expand Down Expand Up @@ -176,7 +178,7 @@ export const AsideHeaderShowcase: FC<AsideHeaderShowcaseProps> = ({
},
}}
bringForward
openModalSubscriber={isModalOpen ? openModalSubscriber : undefined}
openModalSubscriber={openModalSubscriber}
compact={compact}
/>
<FooterItem
Expand Down

0 comments on commit f077aad

Please sign in to comment.