diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-01-09 13:21:57 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-01-09 13:21:57 -0400 |
commit | ebeac7ba40450962bfba46c9c7b9d7eefb829225 (patch) | |
tree | 694d0d375ed0f30c67f6deab838839ab2c679d1f | |
parent | 708698289ab1a544c2ce066ade7171ff87108f82 (diff) |
client: hide tooltip right away when clicking elsewhere
-rw-r--r-- | src/static/client3.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/static/client3.js b/src/static/client3.js index 35d9ab69..deeac6aa 100644 --- a/src/static/client3.js +++ b/src/static/client3.js @@ -1032,6 +1032,33 @@ function addHoverableTooltipPageListeners() { hideCurrentlyShownTooltip(); } }); + + document.body.addEventListener('click', domEvent => { + const {clientX, clientY} = domEvent; + + const pointIsOverHoverableOrTooltip = + pointIsOverAnyOf(getHoverablesAndTooltips()); + + if (!pointIsOverHoverableOrTooltip(clientX, clientY)) { + // Hide with "intent to replace" - we aren't actually going to replace + // the tooltip with a new one, but this intent indicates that it should + // be hidden right away, instead of showing. What we're really replacing, + // or rather removing, is the state of interacting with tooltips at all. + hideCurrentlyShownTooltip(true); + + // Part of that state is fast hovering, which should be canceled out. + state.fastHovering = false; + if (state.endFastHoveringTimeout) { + clearTimeout(state.endFastHoveringTimeout); + state.endFastHoveringTimeout = null; + } + + // Also cancel out of transitioning a tooltip hidden - this isn't caught + // by `hideCurrentlyShownTooltip` because a transitioning-hidden tooltip + // doesn't count as "shown" anymore. + cancelTransitioningTooltipHidden(); + } + }); } clientSteps.addPageListeners.push(addHoverableTooltipPageListeners); |