-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52446 from bernhardoj/fix/51987-missing-tooltip-f…
…or-qab Fix tooltip for QAB doesn't show for new user
- Loading branch information
Showing
4 changed files
with
51 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/components/Tooltip/EducationalTooltip/TooltipManager.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// We store the timeouts for each pending tooltip here. | ||
// We're using the timeout because when a tooltip is used inside an animated view (e.g., popover), | ||
// we need to wait for the animation to finish before measuring content. | ||
const pendingTooltips = new Set<NodeJS.Timeout>(); | ||
|
||
// We store the callback for closing a tooltip here. | ||
const activeTooltips = new Set<() => void>(); | ||
|
||
function addPendingTooltip(timeout: NodeJS.Timeout) { | ||
pendingTooltips.add(timeout); | ||
return () => { | ||
pendingTooltips.delete(timeout); | ||
}; | ||
} | ||
|
||
function addActiveTooltip(closeCallback: () => void) { | ||
activeTooltips.add(closeCallback); | ||
return () => { | ||
activeTooltips.delete(closeCallback); | ||
}; | ||
} | ||
|
||
function cancelPendingAndActiveTooltips() { | ||
pendingTooltips.forEach((timeout) => clearTimeout(timeout)); | ||
pendingTooltips.clear(); | ||
activeTooltips.forEach((closeCallback) => closeCallback()); | ||
activeTooltips.clear(); | ||
} | ||
|
||
export {addPendingTooltip, addActiveTooltip, cancelPendingAndActiveTooltips}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters