Show a check icon instead of a tooltip after copying in GlClipboardButton
What does this MR do?
GlClipboardButton confirmed a copy by changing its tooltip title and aria-label to "Copied" (or "Copy failed") for 1 second. This MR makes it behave like ClipboardButton in GitLab after gitlab-org/gitlab!260229 (merged).
After copying, the button now:
- shows the
checkicon for 2 seconds (theerroricon if copying failed), then goes back to the copy icon. Copying again restarts the 2 seconds; - announces the result ("Copied" or "Copy failed") to screen readers with
ariaNotify().
The tooltip title and the aria-label always stay the title.
Pajamas recommends an inline confirmed state on the control itself for clipboard actions, "such as a copy button that briefly shows a check": https://design.gitlab.com/patterns/choosing-a-messaging-pattern
In GitLab, GlClipboardButton is only used through GlBreadcrumb (show-clipboard-button), for example in the repository file breadcrumbs.
Why ariaNotify, and why no polyfill here
Changing the accessible name to "Copied" was announced inconsistently in screen reader testing (NVDA and VoiceOver announce name changes of the focused button, JAWS and TalkBack don't), and changing it back was read out as a second announcement. See the discussion in gitlab-org/gitlab!260229 (merged). ariaNotify() announces a status message that isn't tied to a DOM change or to focus.
ariaNotify() is Baseline 2026 (newly available), so not all supported browsers have it. GitLab UI doesn't ship runtime polyfills: it dropped its last one (resize-observer-polyfill) in v32.0.0 and asked consumers to polyfill it themselves. So this MR calls this.$el.ariaNotify?.(message). Without it, the icon still changes, but nothing is announced. GitLab loads @github/arianotify-polyfill in commons/polyfills.js with gitlab-org/gitlab!260229 (merged), so that MR should be merged before, or together with, the @gitlab/ui bump that includes this change.
Screenshots or screen recordings
| Before | After |
|---|---|
How to set up and validate locally
- Run Storybook and open the
GlBreadcrumb"With Clipboard Button" story. - Hover the copy button: the tooltip shows "Copy to clipboard".
- Click it: the icon changes to a check, and the tooltip keeps showing "Copy to clipboard".
- After 2 seconds, the copy icon is back.
- Optional, with a screen reader in a browser with native
ariaNotify()(Chrome/Edge 141+, Firefox 150+, Safari 27+): after clicking, "Copied" is announced. The button's name doesn't change.
Integrations
No API changes. GitLab announces "Copied to clipboard." in its own ClipboardButton (changed in the accessibility review of gitlab-org/gitlab!260229 (merged)). To announce the same here, the GitLab integration MR should change the mapping in app/assets/javascripts/commons/gitlab_ui.js to 'ClipboardButton.copied': __('Copied to clipboard.'). The default text in GitLab UI stays "Copied".
- GitLab: mr_url (Run the
ui:create_integration_merge_requestCI job, which automatically creates the merge request and updates this item for you.)
Does this MR meet the acceptance criteria?
This checklist encourages the authors, reviewers, and maintainers of merge requests (MRs) to confirm changes were analyzed for conformity with the project's guidelines, security and accessibility.
Toggle the acceptance checklist
Conformity
- The “What does this MR do?” section in the MR description is filled out, explaining the reasons for and scope of the proposed changes, per “Say why not just what”.
- For example, if the MR is focused on usage guidelines, addressing accessibility challenges could be added in a separate MR.
- Relevant label(s) are applied to the MR.
- The MR is added to a milestone.
- Added the
~"component:*"label(s) if applicable. - A changeset is added when this MR will do a patch, minor, or major update. More information can be found in
doc/changesets.md.
Components
- GitLab UI's contributing guidelines.
- If the MR changes a component's API, integration MR(s) have been opened (see integrations above).
Accessibility
If this MR adds or modifies a component, take a few moments to review the following:
- All actions and functionality can be done with a keyboard.
- Links, buttons, and controls have a visible focus state.
- All content is presented in text or with a text equivalent. For example, alt text for SVG, or
aria-labelfor icons that have meaning or perform actions. - Changes in a component’s state are announced by a screen reader. For example, changing
aria-expanded="false"toaria-expanded="true"when an accordion is expanded. - Color combinations have sufficient contrast.