Fix BackpexTooltip lingering after the hooked element is clicked#1920
Merged
Conversation
The hook only listened for mouseenter/mouseleave. Clicking the element (for example a row Delete action) often opens a confirm modal or triggers a server event without moving the cursor off the element, so mouseleave never fires and the tooltip stays pinned above the page. For actions that morph the element in place (e.g. status updates), the tooltip can linger indefinitely because destroyed() is not invoked. Add a click listener on the hooked element that clears the tooltip, using the existing AbortController signal so it is torn down with the other listeners.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds explicit tooltip cleanup on click to prevent BackpexTooltip from lingering when the hooked element is clicked (e.g., opening a modal or triggering a LiveView event without firing mouseleave).
Changes:
- Add a
clicklistener to remove and null out the tooltip when the hooked element is clicked. - Apply the change to the source hook and both distributed bundles (ESM + CJS).
Reviewed changes
Copilot reviewed 3 out of 5 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
assets/js/hooks/_tooltip.js |
Adds click-based tooltip cleanup using the existing AbortController signal. |
priv/static/js/backpex.esm.js |
Mirrors the tooltip click cleanup in the ESM bundle. |
priv/static/js/backpex.cjs.js |
Mirrors the tooltip click cleanup in the CJS bundle. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address PR review feedback: the cleanup logic was duplicated across mouseleave, click, and destroyed. Extract it into a single removeTooltip() helper so future state resets stay consistent.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BackpexTooltiphook only listened formouseenter/mouseleaveto show and hide its tooltip. Clicking the hooked element (e.g. a rowDeleteaction) typically opens a confirm modal or triggers a server event without moving the cursor off the element, somouseleavenever fires and the tooltip stays pinned above the page.destroyed()callback never fires — the element is morphed, not destroyed.clicklistener onthis.elthat clears the tooltip, reusing the existingAbortControllersignal so it is torn down cleanly alongside the other listeners.