Skip to content

Fix BackpexTooltip lingering after the hooked element is clicked#1920

Merged
pehbehbeh merged 2 commits into
developfrom
fix/tooltip-click-dismissal
Apr 22, 2026
Merged

Fix BackpexTooltip lingering after the hooked element is clicked#1920
pehbehbeh merged 2 commits into
developfrom
fix/tooltip-click-dismissal

Conversation

@Flo0807
Copy link
Copy Markdown
Collaborator

@Flo0807 Flo0807 commented Apr 15, 2026

Summary

  • The BackpexTooltip hook only listened for mouseenter / mouseleave to show and hide its tooltip. Clicking the hooked element (e.g. a row Delete action) typically 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 item actions that mutate the row in place (e.g. status toggles), the tooltip can linger indefinitely because the hook's destroyed() callback never fires — the element is morphed, not destroyed.
  • Add a click listener on this.el that clears the tooltip, reusing the existing AbortController signal so it is torn down cleanly alongside the other listeners.

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.
@Flo0807 Flo0807 added the bug Something isn't working label Apr 15, 2026
@Flo0807 Flo0807 requested a review from Copilot April 15, 2026 10:06
@Flo0807 Flo0807 self-assigned this Apr 15, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 click listener 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.

Comment thread assets/js/hooks/_tooltip.js Outdated
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.
@Flo0807 Flo0807 requested a review from pehbehbeh April 22, 2026 05:06
@pehbehbeh pehbehbeh added this pull request to the merge queue Apr 22, 2026
Merged via the queue into develop with commit 0a9bdf5 Apr 22, 2026
7 checks passed
@pehbehbeh pehbehbeh deleted the fix/tooltip-click-dismissal branch April 22, 2026 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants