From 49e3deaf9adf73047e988d64679a6edfe9bebba5 Mon Sep 17 00:00:00 2001 From: Angelina Gadzhieva Date: Thu, 7 Sep 2023 19:35:40 +0300 Subject: [PATCH 1/3] fix(CompositeBar): fix multipleTooltip sticking --- src/components/CompositeBar/CompositeBar.tsx | 31 ++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/components/CompositeBar/CompositeBar.tsx b/src/components/CompositeBar/CompositeBar.tsx index 2f2c5b7..e5efbf6 100644 --- a/src/components/CompositeBar/CompositeBar.tsx +++ b/src/components/CompositeBar/CompositeBar.tsx @@ -53,6 +53,7 @@ const CompositeBarView: FC = ({ }) => { const ref = useRef>(null); const tooltipRef = useRef(null); + const { setValue: setMultipleTooltipContextValue, active: multipleTooltipActive, @@ -61,10 +62,29 @@ const CompositeBarView: FC = ({ } = useContext(MultipleTooltipContext); const {compact} = useAsideHeaderContext(); + React.useEffect(() => { + function handleBlurWindow() { + if (multipleTooltip) { + if (multipleTooltipActive) { + setMultipleTooltipContextValue({active: false}); + } + } + } + + window.addEventListener('blur', handleBlurWindow); + + return () => { + window.removeEventListener('blur', handleBlurWindow); + }; + }, [multipleTooltip, multipleTooltipActive, setMultipleTooltipContextValue]); + const onTooltipMouseEnter = useCallback( (e) => { if ( + multipleTooltip && + compact && !multipleTooltipActive && + document.hasFocus() && activeIndex !== lastClickedItemIndex && e.clientX <= ASIDE_HEADER_COMPACT_WIDTH ) { @@ -73,11 +93,18 @@ const CompositeBarView: FC = ({ }); } }, - [multipleTooltipActive, activeIndex, lastClickedItemIndex, setMultipleTooltipContextValue], + [ + multipleTooltip, + compact, + multipleTooltipActive, + activeIndex, + lastClickedItemIndex, + setMultipleTooltipContextValue, + ], ); const onTooltipMouseLeave = useCallback(() => { - if (multipleTooltipActive) { + if (multipleTooltip && multipleTooltipActive && document.hasFocus()) { setMultipleTooltipContextValue?.({ active: false, lastClickedItemIndex: undefined, From 4f7e013aa168b16842e01d77dd85ff1e0b837902 Mon Sep 17 00:00:00 2001 From: Angelina Gadzhieva Date: Fri, 8 Sep 2023 16:52:35 +0300 Subject: [PATCH 2/3] chore: fix pr --- src/components/CompositeBar/CompositeBar.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/components/CompositeBar/CompositeBar.tsx b/src/components/CompositeBar/CompositeBar.tsx index e5efbf6..2c4eb9a 100644 --- a/src/components/CompositeBar/CompositeBar.tsx +++ b/src/components/CompositeBar/CompositeBar.tsx @@ -64,10 +64,8 @@ const CompositeBarView: FC = ({ React.useEffect(() => { function handleBlurWindow() { - if (multipleTooltip) { - if (multipleTooltipActive) { - setMultipleTooltipContextValue({active: false}); - } + if (multipleTooltip && multipleTooltipActive) { + setMultipleTooltipContextValue({active: false}); } } From d4965a9aed9186c6efd233804e3ef6b6f02c8abf Mon Sep 17 00:00:00 2001 From: Angelina Gadzhieva Date: Fri, 8 Sep 2023 16:54:21 +0300 Subject: [PATCH 3/3] fix(AsideHeaderShowcase): reorder cases in if --- src/components/AsideHeader/__stories__/AsideHeaderShowcase.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/AsideHeader/__stories__/AsideHeaderShowcase.tsx b/src/components/AsideHeader/__stories__/AsideHeaderShowcase.tsx index 45250a6..3a48266 100644 --- a/src/components/AsideHeader/__stories__/AsideHeaderShowcase.tsx +++ b/src/components/AsideHeader/__stories__/AsideHeaderShowcase.tsx @@ -48,7 +48,7 @@ export const AsideHeaderShowcase: FC = ({ // @ts-ignore eventBroker.subscribe((data: EventBrokerData<{layersCount: number}>) => { if (data?.eventId === 'layerschange') { - callback(data?.meta?.layersCount !== 0 && isModalOpen); + callback(isModalOpen && data?.meta?.layersCount !== 0); } }); };