Skip to content

Commit

Permalink
fix restored tour
Browse files Browse the repository at this point in the history
  • Loading branch information
Dosant committed Feb 4, 2021
1 parent 19fd9c9 commit 30d976d
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ export function useSearchSessionTour(
if (state === SearchSessionState.Loading) {
if (!safeHas(storage, TOUR_TAKING_TOO_LONG_STEP_KEY)) {
timeoutHandle = window.setTimeout(() => {
searchSessionIndicatorRef.current?.openPopover();
safeOpen(searchSessionIndicatorRef);
}, TOUR_TAKING_TOO_LONG_TIMEOUT);
}
}

if (state === SearchSessionState.Restored) {
if (!safeHas(storage, TOUR_RESTORE_STEP_KEY)) {
searchSessionIndicatorRef.current?.openPopover();
safeOpen(searchSessionIndicatorRef);
}
}

Expand Down Expand Up @@ -79,3 +79,15 @@ function safeSet(storage: IStorageWrapper, key: string) {
return true;
}
}

function safeOpen(searchSessionIndicatorRef: MutableRefObject<SearchSessionIndicatorRef | null>) {
if (searchSessionIndicatorRef.current) {
searchSessionIndicatorRef.current.openPopover();
} else {
// TODO: needed for initial open when component is not rendered yet
// fix after: https://github.com/elastic/eui/issues/4460
setTimeout(() => {
searchSessionIndicatorRef.current?.openPopover();
}, 50);
}
}

0 comments on commit 30d976d

Please sign in to comment.