Skip to content

Fix copy token tooltip clipping and icon flicker#4590

Open
m4cd4r4 wants to merge 2 commits intoOpenFn:mainfrom
m4cd4r4:fix/token-copy-ui
Open

Fix copy token tooltip clipping and icon flicker#4590
m4cd4r4 wants to merge 2 commits intoOpenFn:mainfrom
m4cd4r4:fix/token-copy-ui

Conversation

@m4cd4r4
Copy link
Copy Markdown

@m4cd4r4 m4cd4r4 commented Apr 1, 2026

Description

Fixes #2463 - UI inconsistency when copying the user API token.

Two bugs existed on the Personal Access Tokens page (/profile/tokens):

  1. No visible 'Copied!' feedback - the copy button had no phx-hook="Tooltip" ancestor, so showCopiedTooltip() in the Copy hook silently no-opped (this.el.closest('[phx-hook="Tooltip"]') returned null). The only feedback was a flash message at the bottom of the screen.

  2. Icon flicker on click - phx-then={JS.push("copy")} sent a server event on every click, which triggered a LiveView diff/repaint that caused the clipboard icon to flicker.

Fix: Wrap the copy button in a <span phx-hook="Tooltip"> with aria-label="Copy to clipboard" and data-hide-on-click="false". The existing showCopiedTooltip() mechanism then works correctly - tippy.js shows 'Copied!' for 1.5s and resets. This matches the established pattern in channel_live/form_component.ex.

The server-side handle_event("copy", ...) handler and phx-then attribute are removed - feedback is now handled client-side, consistent with other copy UIs in the codebase.

Changed overflow-auto to overflow-hidden on the token container - this prevents unexpected scrollbars while keeping rounded corner clipping.

Validation steps

  1. Go to /profile/tokens and generate a new token
  2. Hover the clipboard icon - tooltip reads "Copy to clipboard"
  3. Click the clipboard icon - tooltip immediately shows "Copied!" for 1.5s, then resets
  4. Paste the token somewhere to confirm the clipboard contents are correct
  5. Confirm the clipboard icon does not flicker or disappear during steps 2-4

AI Usage

  • I have used Claude Code
  • I have used another model
  • I have not used AI

Pre-submission checklist

  • I have performed an AI review of my code (we recommend using /review with Claude Code)
  • I have implemented and tested all related authorization policies.
  • I have updated the changelog.
  • I have ticked a box in "AI usage" in this PR

Wrap the copy button in a Tooltip span so the existing
showCopiedTooltip() mechanism can find a parent and show
'Copied!' via tippy.js (rendered outside any overflow context).

Previously:
- showCopiedTooltip() found no parent phx-hook='Tooltip'
  and silently no-opped - no visual feedback on the button
- phx-then={JS.push('copy')} triggered a server round-trip
  that caused a LiveView diff/repaint, making the icon flicker

Now:
- Tooltip wrapper shows 'Copy to clipboard' on hover and
  'Copied!' for 1.5s after click, consistent with other
  copy UIs in the codebase (e.g. channel_live/form_component)
- Removed the server-side handle_event('copy') handler and
  the phx-then attribute - feedback is handled client-side
- Changed overflow-auto to overflow-hidden on the container
  so rounded corners clip properly without adding scrollbars
@github-project-automation github-project-automation bot moved this to New Issues in Core Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New Issues

Development

Successfully merging this pull request may close these issues.

UI inconsistency when copying user API token

1 participant