Skip to content

Commit

Permalink
fix: fixes state sharing between tours of different pages (amundsen-i…
Browse files Browse the repository at this point in the history
…o#1854)

Signed-off-by: Marcos Iglesias <miglesiasvalle@lyft.com>
  • Loading branch information
Golodhros authored and Zachary Ruiz committed May 13, 2022
1 parent c5146af commit 13ceffc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const Tour: React.FC<TourProps> = ({
};
// Disabling exhaustive-deps as listening for hasSeenTour would make it impossible to test the feature
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [triggersOnFirstView]);
}, [triggersOnFirstView, triggerFlagId]);

const handleCallback = (data: CallBackProps) => {
const { status } = data;
Expand All @@ -119,7 +119,6 @@ export const Tour: React.FC<TourProps> = ({
<Joyride
run={run || runTourOnFirstView}
steps={steps}
key={triggerFlagId} // This resets the tour component on each page
callback={handleCallback}
// eslint-disable-next-line react/jsx-props-no-spreading
{...configuration}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,16 @@ export const NavBar: React.FC<NavBarProps> = ({ loggedInUser, location }) => {
const { hasPageTour, pageTourKey, pageTourSteps } = getPageTourInfo(
location.pathname
);

const {
hasFeatureTour,
featureTourKey,
featureTourSteps,
} = getFeatureTourInfo(location.pathname);

React.useEffect(() => {
setRunTour(false);
}, [location.pathname]);

const userLink = `/user/${loggedInUser.user_id}?source=navbar`;
let avatar = <div className="shimmering-circle is-shimmer-animated" />;

Expand Down Expand Up @@ -245,6 +248,7 @@ export const NavBar: React.FC<NavBarProps> = ({ loggedInUser, location }) => {
steps={hasPageTour ? pageTourSteps : featureTourSteps}
onTourEnd={handleTourEnd}
triggersOnFirstView
key={hasPageTour ? pageTourKey : featureTourKey} // Re-renders tour on each page
triggerFlagId={hasPageTour ? pageTourKey : featureTourKey}
/>
)}
Expand Down

0 comments on commit 13ceffc

Please sign in to comment.