Skip to content

Render tooltip only when help pane is hidden #58104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
6 changes: 4 additions & 2 deletions src/components/ProductTrainingContext/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as Expensicons from '@components/Icon/Expensicons';
import Text from '@components/Text';
import useLocalize from '@hooks/useLocalize';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useSidePane from '@hooks/useSidePane';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import {parseFSAttributes} from '@libs/Fullstory';
Expand Down Expand Up @@ -164,6 +165,7 @@ const useProductTrainingContext = (tooltipName: ProductTrainingTooltipName, shou
const context = useContext(ProductTrainingContext);
const styles = useThemeStyles();
const theme = useTheme();
const {shouldHideToolTip} = useSidePane();
const {translate} = useLocalize();

if (!context) {
Expand Down Expand Up @@ -253,8 +255,8 @@ const useProductTrainingContext = (tooltipName: ProductTrainingTooltipName, shou
]);

const shouldShowProductTrainingTooltip = useMemo(() => {
return shouldShow && shouldRenderTooltip(tooltipName);
}, [shouldRenderTooltip, tooltipName, shouldShow]);
return shouldShow && shouldRenderTooltip(tooltipName) && !shouldHideToolTip;
}, [shouldRenderTooltip, tooltipName, shouldShow, shouldHideToolTip]);

const hideProductTrainingTooltip = useCallback(() => {
if (!shouldShowProductTrainingTooltip) {
Expand Down
7 changes: 6 additions & 1 deletion src/hooks/useSidePane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ function useSidePane() {
const shouldApplySidePaneOffset = isExtraLargeScreenWidth && !isPaneHidden;

const [shouldHideSidePane, setShouldHideSidePane] = useState(true);
const [isAnimating, setIsAnimating] = useState(false);

const shouldHideSidePaneBackdrop = isPaneHidden || isExtraLargeScreenWidth || shouldUseNarrowLayout;

// The help button is hidden in production if the side pane nvp is not present or the language is unsupported.
Expand All @@ -52,7 +54,7 @@ function useSidePane() {
if (!isPaneHidden) {
setShouldHideSidePane(false);
}

setIsAnimating(true);
Animated.parallel([
Animated.timing(sidePaneOffset.current, {
toValue: shouldApplySidePaneOffset ? variables.sideBarWidth : 0,
Expand All @@ -66,16 +68,19 @@ function useSidePane() {
}),
]).start(() => {
setShouldHideSidePane(isPaneHidden);
setIsAnimating(false);
});
}, [isPaneHidden, shouldApplySidePaneOffset, shouldUseNarrowLayout, sidePaneWidth]);

const shouldHideToolTip = isExtraLargeScreenWidth ? isAnimating : !shouldHideSidePane;
return {
sidePane: sidePaneNVP,
shouldHideSidePane,
shouldHideSidePaneBackdrop,
shouldHideHelpButton,
sidePaneOffset,
sidePaneTranslateX,
shouldHideToolTip,
};
}

Expand Down
Loading