Skip to content

fix(popover): replace displayName checks#21550

Merged
tay1orjones merged 3 commits intocarbon-design-system:mainfrom
adamalston:n/a-popover
Apr 2, 2026
Merged

fix(popover): replace displayName checks#21550
tay1orjones merged 3 commits intocarbon-design-system:mainfrom
adamalston:n/a-popover

Conversation

@adamalston
Copy link
Copy Markdown
Contributor

No issue.

Replaced displayName checks in Popover.

Changelog

Changed

  • Replaced displayName checks in Popover.

Testing / Reviewing

Run tests.

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

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.39%. Comparing base (5c4dd5b) to head (95ec0c3).
⚠️ Report is 66 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #21550      +/-   ##
==========================================
- Coverage   94.39%   94.39%   -0.01%     
==========================================
  Files         536      536              
  Lines       43679    43675       -4     
  Branches     6278     6266      -12     
==========================================
- Hits        41232    41228       -4     
  Misses       2308     2308              
  Partials      139      139              
Flag Coverage Δ
main-packages 87.84% <100.00%> (+<0.01%) ⬆️
web-components 97.80% <ø> (-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.

@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 14, 2026

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 95ec0c3
🔍 Latest deploy log https://app.netlify.com/projects/v11-carbon-react/deploys/69b9fff219e3cf00080f88e1
😎 Deploy Preview https://deploy-preview-21550--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.

@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 14, 2026

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

Name Link
🔨 Latest commit 95ec0c3
🔍 Latest deploy log https://app.netlify.com/projects/v11-carbon-web-components/deploys/69b9fff29bad180008848a03
😎 Deploy Preview https://deploy-preview-21550--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.

Comment on lines +478 to +484
// TODO: Stop relying on `displayName` checks by moving `Toggletip`
// subcomponents into their own files that avoid the `Popover` <->
// `Toggletip` circular dependency. Then replace these `displayName` checks
// with `isComponentElement(item, ...)` checks.
const isToggletipButton = item?.type?.displayName === 'ToggletipButton';
const isToggletipContent = item?.type?.displayName === 'ToggletipContent';
const isPopoverContent = isComponentElement(item, PopoverContent);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Harkening back to this conversation, #18971 (comment), I just want to call out that removing the implicit displayName duck typing could theoretically break some setups. Not a blocker to merge though.

Also, these checks intentionally relied on the displayName duck typing to fix this issue, #17225. I wrote a test for it though. So, if that's passing, and the Toggletip autoAlign stories look good, then I think all the bases are covered?

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.

I think all the bases are covered?

I’m not sure whether that question was directed at me, but if it was, I agree. Hopefully, we can remove all displayName based functionality from the codebase by the time v12 is released.

(enableFloatingStyles &&
item?.type['displayName'] === 'ToggletipButton')
) {
if (enableFloatingStyles && !isPopoverContent) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It does appear like part of the original conditional is lost here. It originally fell into this block also when the item is a ToggletipButton.

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.

I don't think this code change resulted in a behavioral difference.

The previous condition was:

(enableFloatingStyles && item?.type !== PopoverContent) ||
(enableFloatingStyles && item?.type['displayName'] === 'ToggletipButton')

Because the two checks were combined using the logical OR operator, the ToggletipButton clause would only have affected behavior if the first condition evaluated to false for ToggletipButton. However, that is not the case. ToggletipButton already satisfies item?.type !== PopoverContent, so it entered the block previously. It continues to do so under the updated condition, enableFloatingStyles && !isPopoverContent.

In other words, this change simplifies the logic by removing a redundant clause without changing its behavior.

If you are seeing a regression in a specific story or test, could you share the details so I can take a look?

@adamalston
Copy link
Copy Markdown
Contributor Author

I'm not sure what the next step should be here.

Copy link
Copy Markdown
Member

@tay1orjones tay1orjones left a comment

Choose a reason for hiding this comment

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

Sorry for the delay, this looks good to me.

@tay1orjones tay1orjones added this pull request to the merge queue Apr 2, 2026
Merged via the queue into carbon-design-system:main with commit 0f0fbbe Apr 2, 2026
38 checks passed
@adamalston adamalston deleted the n/a-popover branch April 3, 2026 03:38
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.

3 participants