Skip to content

Enable click and long-press copying of user ID/internal link in user profile dialog#36

Merged
wsxiaolin merged 2 commits into
mainfrom
codex/add-user-id-and-username-copy-feature
May 10, 2026
Merged

Enable click and long-press copying of user ID/internal link in user profile dialog#36
wsxiaolin merged 2 commits into
mainfrom
codex/add-user-id-and-username-copy-feature

Conversation

@gushishang

Copy link
Copy Markdown
Member

Motivation

  • Let users quickly copy a user's ID or an internal user-link from the profile dialog to streamline sharing and referencing.
  • Provide both a single-tap copy (user ID) and a long-press copy (internal link format) to support desktop and touch interactions.

Description

  • Imported copyText from @services/utils and added copyTextWithMessage to show success/error feedback using showMessage.
  • Added LONG_PRESS_MS, a press timer, and a didLongPress flag to distinguish long-press from click, with onNamePressStart and onNamePressEnd handlers to manage timing.
  • Implemented copyUserID for single-click copying and copyUserInternalLink for long-press copying of the <user=ID>name</user> formatted link, and wired those to the username element via @click, touch, and mouse events.
  • Prevented accidental double actions by ignoring the click action when a long-press has been detected and ensured timers are cleared on end/cancel events.

Testing

  • Ran the project build with npm run build and the build completed successfully.
  • Executed the test suite with npm test and all automated tests passed.
  • Verified the new clipboard flow by running the dev server and observing the success/error messages from showMessage during copy operations.

Codex Task

@gushishang

Copy link
Copy Markdown
Member Author

@codex

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 09701e38ae

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +16 to +20
@touchstart="onNamePressStart"
@touchend="onNamePressEnd"
@touchcancel="onNamePressEnd"
@mousedown="onNamePressStart"
@mouseup="onNamePressEnd"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Prevent emulated mouse events from overriding long-press copy

Binding both touch* and mouse* press handlers to the same element causes a touch interaction to be processed twice on mobile browsers that emit compatibility mouse events after touch (as documented by MDN). In a long-press flow, touchstart triggers the timer and copies the internal link, but the later emulated mousedown resets didLongPress, so the final click path copies the plain user ID and overwrites the clipboard result. This makes long-press copy unreliable on touch devices unless you suppress compatibility mouse events (e.g., preventDefault) or switch to pointer events.

Useful? React with 👍 / 👎.

@wsxiaolin wsxiaolin merged commit fd2633a into main May 10, 2026
1 check passed
@wsxiaolin wsxiaolin deleted the codex/add-user-id-and-username-copy-feature branch May 10, 2026 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants