Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Svelte: QoL fixes for hover popovers#62974

Merged
camdencheek merged 8 commits into
mainfrom
cc/hover-delay
May 30, 2024
Merged

Svelte: QoL fixes for hover popovers#62974
camdencheek merged 8 commits into
mainfrom
cc/hover-delay

Conversation

@camdencheek

@camdencheek camdencheek commented May 29, 2024

Copy link
Copy Markdown
Member

Fixes SRCH-449

Each commit is granular and has a useful message describing the change.

In short:

  • Adds a hoverDelay parameter to Popover so each consumer doesn't need to do this manually
  • Makes hovers only show when the mouse comes to rest
  • Closes the popover when the window loses focus so we don't miss a mouseleave event and have popovers get stuck open
  • Adds a delay to popover closing when the mouse leaves one of the target elements so there is room for error when moving the mouse from the trigger to the popover
  • Adds preloading back to the file tree because the popover now does not create the element until the delay has passed
  • Makes it so clicking the target closes the popover when hover is enabled.

Test plan

Manual testing for feel. Would love if reviewers would pull this down and try it out on the file tree.

Video walkthrough

Adds a configurable hover delay to hover-enabled popovers.
Resets the delay on mousemove within the element so we only show the
popover when the mouse comes to rest on the trigger element.
This closes the popover when the window loses focus and hover is enabled
because losing focus means we can miss the mouse move event, which
causes the popover to be stuck open.
This adds a small delay to closing the popover when the mouse leaves
either the trigger element or the popover element so that there is some
room for error when moving the mouse from the trigger into the popover.
@cla-bot cla-bot Bot added the cla-signed label May 29, 2024
Just a few code simplifications. No behavior change.
Fetches data on hover so it's available in the cache.
node.removeEventListener('mouseenter', handleMouseEnterTrigger)
node.removeEventListener('mouseleave', handleMouseLeaveTrigger)
node.removeEventListener('mousemove', handleMouseMoveTrigger)
window.removeEventListener('blur', handleWindowLoseFocus)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one more situation that can cause this. If I re-tile my window so the window moves behind my mouse, a mouseleave event is not triggered and the popover does not disappear. The only way I could think of to get around this would be to add an event on mousemove and check if the mouse ever appears outside of the popover, but that sounded expensive

@camdencheek camdencheek requested a review from a team May 29, 2024 20:38
@camdencheek camdencheek force-pushed the cc/hover-delay branch 2 times, most recently from ead00e1 to 4565bd3 Compare May 29, 2024 21:31
Previously, we were only hiding when a click occurred outside the target
element. However, we already hide the popover in hover mode when the
mouse leaves the popover and trigger. In this case, we want a click on
the trigger to hide the popover.
Comment thread client/web-sveltekit/src/lib/Popover.svelte Outdated
@camdencheek camdencheek enabled auto-merge (squash) May 30, 2024 14:17
@camdencheek camdencheek merged commit 819b2d0 into main May 30, 2024
@camdencheek camdencheek deleted the cc/hover-delay branch May 30, 2024 15:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants