Skip to content

[Integrate-2755] add copy tooltip and tick feedback to Text component copy button - #3046

Open
suwarnoong wants to merge 1 commit into
developfrom
suwarnoong/2755
Open

[Integrate-2755] add copy tooltip and tick feedback to Text component copy button#3046
suwarnoong wants to merge 1 commit into
developfrom
suwarnoong/2755

Conversation

@suwarnoong

@suwarnoong suwarnoong commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Merge Checklist

Screen.Recording.2026-08-04.at.16.07.05.mov

Please cross check this list if additions / modifications needs to be done on top of your core changes and tick them off. Reviewer can as well glance through and help the developer if something is missed out.

  • Automated Tests (Jasmine integration tests, Unit tests, and/or Performance tests)
  • Updated Manual tests / Demo Config
  • Documentation (Application guide, Admin guide, Markdown, Readme and/or Wiki)
  • Verified that local development environment is working with latest changes (integrated with latest develop branch)
  • following best practices in code review doc

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds UX feedback for the Text component’s copy button in portal-components, including a hover tooltip and a temporary “copied” checkmark state after clicking copy.

Changes:

  • Add tooltip-wrapped copy button UI and a 3s “copied” feedback state in Text.
  • Add Jest/RTL tests for tooltip visibility, icon swap timing, repeated clicks, and unmount cleanup.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
plugins/ui/libs/portal-components/src/components/Text/Text.tsx Adds tooltip + “copied” feedback state to the Text copy button.
plugins/ui/libs/portal-components/src/components/Text/tests/Text.test.tsx Adds unit tests covering tooltip and copied-state timing/reset behavior.

Comment on lines 32 to 40
const handleCopyString = useCallback((content: string) => {
navigator.clipboard.writeText(content);
setCopied(true);
if (resetTimeoutRef.current) clearTimeout(resetTimeoutRef.current);
resetTimeoutRef.current = setTimeout(() => {
setCopied(false);
resetTimeoutRef.current = null;
}, COPY_FEEDBACK_DURATION_MS);
}, []);
Comment on lines +60 to +63
<IconButton
startIcon={copied ? <CheckIcon width={24} height={24} /> : <CopyIcon width={24} height={24} />}
onClick={() => handleCopyString(props.children)}
/>
Comment on lines +7 to +17
beforeEach(() => {
writeText.mockClear();
// navigator.clipboard is non-writable in jsdom by default, so it must be
// redefined rather than assigned — same pattern used in
// apps/vue-mri-ui-lib/src/utils/__tests__/CohortUrlCodec.test.ts.
Object.defineProperty(navigator, "clipboard", {
value: { writeText },
writable: true,
configurable: true,
});
});
Comment on lines +25 to +29
// Both CopyIcon and CheckIcon render their meaningful path with fill="navy" —
// CheckIcon also renders an unfilled background rect path, so this selector
// (not a plain "svg path") is what actually distinguishes the two icons.
function getIconPathData(button: HTMLButtonElement) {
return button.querySelector('svg path[fill="navy"]')?.getAttribute("d") ?? "";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants