Skip to content

[EuiCopy] Trigger tooltip imperatively#9650

Merged
weronikaolejniczak merged 7 commits into
elastic:mainfrom
weronikaolejniczak:fix/copy-tooltip
May 15, 2026
Merged

[EuiCopy] Trigger tooltip imperatively#9650
weronikaolejniczak merged 7 commits into
elastic:mainfrom
weronikaolejniczak:fix/copy-tooltip

Conversation

@weronikaolejniczak
Copy link
Copy Markdown
Contributor

@weronikaolejniczak weronikaolejniczak commented May 12, 2026

Summary

  • What: Called showToolTip after the copy trigger has been clicked.
  • Why: To fix regression after [EuiToolTip] Prevent intercepting pointer events, do not show when content or title empty #9636.
  • How:
    • The reason "Copied" is no longer showing is because the implementation is rendering the tooltip always, with undefined content but relies on the value being flipped from undefined to truthy after the trigger is focused/hovered. EuiToolTip doesn't account for dynamic content change anymore because of the (!content && !title) return; guard in showToolTip. The way to fix it is by calling showToolTip after the trigger has been clicked.
    • Added EuiScreenReaderLive to announce the afterMessage independently of the tooltip. Tooltip won't be re-announced when its content changes dynamically. That's an a11y issue.

API Changes

N/A

Screenshots

Before After
Kapture.2026-05-12.at.20.05.43.mp4
Kapture.2026-05-12.at.20.06.19.mp4

Impact Assessment

Note: Most PRs should be tested in Kibana to help gauge their Impact before merging.

  • 🔴 Breaking changes — What will break? How many usages in Kibana/Cloud UI are impacted?
  • 💅 Visual changes — May impact style overrides; could require visual testing. Explain and estimate impact.
  • 🧪 Test impact — May break functional or snapshot tests (e.g., HTML structure, class names, default values).
  • 🔧 Hard to integrate — If changes require substantial updates to Kibana, please stage the changes and link them here.

Impact level: 🟢 None

Release Readiness

  • Documentation: {link to docs page(s)}
  • Figma: {link to Figma or issue}
  • Migration guide: {steps or link, for breaking/visual changes or deprecations}
  • Adoption plan (new features): {link to issue/doc or outline who will integrate this and where}

QA instructions for reviewer

  • Verify the EuiToolTip shows on clicking the trigger with "Copied!" message (beforeMessage is undefined)
  • Verify the EuiToolTip shows beforeMessage on hover and updates to "Copied!" on clicking the trigger
  • Verify screen readers announce both messages correctly
    • VoiceOver/Safari
    • NVDA/Edge
    • JAWS/Chrome

Checklist before marking Ready for Review

Reviewer checklist

  • Approved Impact Assessment — Acceptable to merge given the consumer impact.
  • Approved Release Readiness — Docs, Figma, and migration info are sufficient to ship.

@weronikaolejniczak weronikaolejniczak self-assigned this May 12, 2026
@weronikaolejniczak weronikaolejniczak marked this pull request as ready for review May 12, 2026 18:07
Copilot AI review requested due to automatic review settings May 12, 2026 18:07
@weronikaolejniczak weronikaolejniczak requested a review from a team as a code owner May 12, 2026 18:07
@weronikaolejniczak weronikaolejniczak changed the title [EuiCopy] Show tooltip imperatively [EuiCopy] Trigger tooltip imperatively May 12, 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

This PR fixes a regression where EuiCopy no longer reliably shows the post-copy tooltip message after recent EuiToolTip behavior changes, and improves accessibility feedback by announcing copy confirmation via a live region.

Changes:

  • Adds an imperative showToolTip() call after a successful copy state update to ensure the tooltip displays when beforeMessage is empty/undefined.
  • Adds EuiScreenReaderLive output to announce the afterMessage independently of tooltip focus/hover behavior.
  • Updates/extends unit tests and adds a changelog entry documenting the fix and a11y improvement.

Reviewed changes

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

File Description
packages/eui/src/components/copy/copy.tsx Imperatively triggers tooltip after copy; adds screen reader live announcement state/rendering.
packages/eui/src/components/copy/copy.test.tsx Adjusts tooltip-related assertions and adds a test for aria-live announcements.
packages/eui/changelogs/upcoming/9650.md Documents the bug fix and accessibility improvement for EuiCopy.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/eui/src/components/copy/copy.tsx Outdated
Comment thread packages/eui/src/components/copy/copy.tsx Outdated
Comment thread packages/eui/src/components/copy/copy.test.tsx
@acstll acstll self-requested a review May 13, 2026 11:32
Copy link
Copy Markdown
Contributor

@acstll acstll left a comment

Choose a reason for hiding this comment

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

Code looks correct, both implementation and tests changes. But i found a behavior that i think is unexpected.

In summary, tabbing away from the button (Tab when focused) after clicking hitting Enter will not clear the 'copied' state, so tabbing back (Shift+Tab) will show the "Copied!" tooltip again (clip 1).

Also, when beforeMessege is set, it won't show while tabbing in, if no mouse-over has previously happened, and the behavior described above is present as well (clip 2).

Some testing with screen readers yielded mixed results for me (i believe it's related to the same issue):

  • NVDA/Edge: "Copied!" is announced twice
  • VoiceOver/Safari: "Copied!" is not being announced
  • VoiceOver/Chrome: no issues found

(did not test with JAWS)

Kapture.2026-05-13.at.16.30.47.mp4
Kapture.2026-05-13.at.16.31.52.mp4

@weronikaolejniczak
Copy link
Copy Markdown
Contributor Author

@acstll that's a great catch! I have no idea how I missed this. The solution was to reset the tooltip on blur:

Kapture.2026-05-14.at.11.42.57.mp4

Now tabbing into and out of the trigger shows the tooltip appropriately.

🟢 VoiceOver/Safari:

Kapture.2026-05-14.at.12.13.24.mp4

🟢 VoiceOver/Chrome:

Kapture.2026-05-14.at.12.14.56.mp4

🟢 NVDA/Edge:

Kapture.2026-05-14.at.12.16.31.mp4

🟢 NVDA/Firefox:

Kapture.2026-05-14.at.12.18.20.mp4

🟢 JAWS/Edge: 🔊

Kapture.2026-05-14.at.12.25.49.mp4

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

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

Comment on lines +104 to +117
disableScreenReaderOutput={
isCopied || !!tooltipProps?.disableScreenReaderOutput
}
>
{children(this.copy)}
</EuiToolTip>
{/* Stable `aria-live` region so VoiceOver/Safari announces reliably.
`EuiScreenReaderLive` alternates `aria-live` between "off" and active which
Safari ignores when attribute and content change in the same render. */}
<EuiScreenReaderOnly>
<div aria-live="assertive" aria-atomic="true">
{isCopied ? afterMessage : ''}
</div>
</EuiScreenReaderOnly>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Suppressing the SR output in this case would be an a11y violation. Let's leave it as is and we can always easily update in the future if any consumer raises this concern.

Comment thread packages/eui/changelogs/upcoming/9650.md Outdated
weronikaolejniczak and others added 2 commits May 14, 2026 12:34
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@elasticmachine
Copy link
Copy Markdown
Collaborator

💚 Build Succeeded

History

cc @weronikaolejniczak

@elasticmachine
Copy link
Copy Markdown
Collaborator

💚 Build Succeeded

History

cc @weronikaolejniczak

Copy link
Copy Markdown
Contributor

@acstll acstll left a comment

Choose a reason for hiding this comment

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

🟢 Thanks for addressing the feedback, super clean fix 👌 (loved the casing in "bEFORE MESSAGE" 🤘)

@weronikaolejniczak weronikaolejniczak merged commit 1c9f8f9 into elastic:main May 15, 2026
5 checks passed
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.

4 participants