Skip to content

fix(aiLabel): link on top of popover fails#21928

Merged
sangeethababu9223 merged 20 commits into
carbon-design-system:mainfrom
sangeethababu9223:fix/ailabel-popover-link-fail
Apr 13, 2026
Merged

fix(aiLabel): link on top of popover fails#21928
sangeethababu9223 merged 20 commits into
carbon-design-system:mainfrom
sangeethababu9223:fix/ailabel-popover-link-fail

Conversation

@sangeethababu9223

@sangeethababu9223 sangeethababu9223 commented Mar 31, 2026

Copy link
Copy Markdown
Member

Closes #21235

Fixes AILabel popover links failing to open when the component is rendered inside Shadow DOM by improving click detection logic in Toggletip.

Changelog

Changed

  • Enhanced Toggletip's outside click detection to properly handle Shadow DOM contexts using composedPath() API
  • Updated click event handling in Toggletip to check the full event path through shadow boundaries, not just the retargeted event.target
  • Updated click event handling in Toggletip to check the full event path through shadow boundaries, not just the retargeted event.target

Testing / Reviewing

  • Navigate to the Shadow DOM Test story in Storybook
  • Test inside click scenario: Click on links and buttons inside the Toggletip content - they should work correctly and the Toggletip should remain open
  • Test outside click scenario: Click outside the Toggletip - it should close properly
  • Verify the Shadow DOM test suite passes

Note: The Shadow DOM Test story (AILabelShadowDemo) was added specifically for manual testing purposes and will be removed after review. While using React AILabel on top of Shadow DOM may seem like an edge case (and the Web Components AILabel would typically be preferred), there are valid scenarios where supporting this use case is beneficial, hence this solution.

Ignore the changes/additions in:
packages/react/src/components/AILabel/AILabel.stories.js packages/react/src/components/AILabel/stories/AILabelShadowDemo.js
as they're only for testing purposes and will be reverted.

PR Checklist

As the author of this PR, before marking ready for review, confirm you:

  • Reviewed every line of the diff
  • [ ]~ Updated documentation and storybook examples~
  • Wrote passing tests that cover this change
  • [ ]Addressed any impact on accessibility (a11y)
  • Tested for cross-browser consistency
  • Validated that this code is ready for review and status checks should pass

More details can be found in the pull request guide

@netlify

netlify Bot commented Mar 31, 2026

Copy link
Copy Markdown

Deploy Preview for v11-carbon-web-components ready!

Name Link
🔨 Latest commit 058ac57
🔍 Latest deploy log https://app.netlify.com/projects/v11-carbon-web-components/deploys/69dc87eebfc2ef0008bff7ff
😎 Deploy Preview https://deploy-preview-21928--v11-carbon-web-components.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Mar 31, 2026

Copy link
Copy Markdown

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 058ac57
🔍 Latest deploy log https://app.netlify.com/projects/v11-carbon-react/deploys/69dc87edb208e5000826e556
😎 Deploy Preview https://deploy-preview-21928--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Mar 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.90%. Comparing base (597001a) to head (058ac57).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #21928      +/-   ##
==========================================
- Coverage   94.90%   94.90%   -0.01%     
==========================================
  Files         541      541              
  Lines       45253    45259       +6     
  Branches     6359     6393      +34     
==========================================
+ Hits        42949    42954       +5     
- Misses       2172     2173       +1     
  Partials      132      132              
Flag Coverage Δ
main-packages 89.16% <100.00%> (+<0.01%) ⬆️
web-components 97.70% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sangeethababu9223 sangeethababu9223 marked this pull request as ready for review April 1, 2026 08:00
@sangeethababu9223 sangeethababu9223 requested a review from a team as a code owner April 1, 2026 08:00
@sangeethababu9223 sangeethababu9223 changed the title fix(aiLabel): link on top over fails fix(aiLabel): link on top of popover fails Apr 1, 2026
Comment thread packages/react/src/components/AILabel/stories/AILabelShadowDemo.js Outdated
Comment thread packages/react/src/components/Toggletip/__tests__/Toggletip-test.js Outdated
Comment thread packages/react/src/components/AILabel/stories/AILabelShadowDemo.js Outdated
Comment thread packages/react/src/components/Toggletip/index.tsx

@maradwan26 maradwan26 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.

LGTM!

Comment thread packages/react/src/components/Toggletip/__tests__/Toggletip-test.js Outdated
Comment thread packages/react/src/components/Toggletip/__tests__/Toggletip-test.js

@adamalston adamalston 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.

I'm ready to approve pending removal of packages/react/src/components/AILabel/stories/AILabelShadowDemo.js.

Comment thread packages/react/src/components/Toggletip/index.tsx Outdated
Comment thread packages/react/src/components/Toggletip/__tests__/Toggletip-test.js Outdated
@sangeethababu9223 sangeethababu9223 added this pull request to the merge queue Apr 13, 2026
Merged via the queue into carbon-design-system:main with commit 04440e6 Apr 13, 2026
39 checks passed
@sangeethababu9223 sangeethababu9223 deleted the fix/ailabel-popover-link-fail branch April 13, 2026 06:42
MarianaAa01 pushed a commit to MarianaAa01/carbon that referenced this pull request May 29, 2026
* fix(aiLabel): link on top over fails

* fix(toggletip): update test and logic to include nested dom

* fix(AIlabel): test story for the change

* fix(Ailabel): story loadig issue

* fix(Ailabel): story loadig issue 2

* fix(AILabel): move storyspecific component to story folder

* fix(AILabel): refactor outside click logic

* refactor(toggletip): clean up comments

* fix(AILabel): shadowDOM test case update

* fix(tooltip): refactor

* fix(Ailabel): remove test only updates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: AILabel popover links fail to open when component is rendered inside Shadow DOM

4 participants