Repository navigation
Conversation
An icon is inline content, but the SVG wrapper was a block <div>, so using an icon inline (e.g. inside Text or a Link) produced invalid DOM nesting (<div> inside <p>/<a>) and React validateDOMNesting warnings. .svg-wrapper is already display: flex, so a <span> renders identically; <span> is phrasing content and legal inline. Layout is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 613aadd The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
XOP
left a comment
There was a problem hiding this comment.
Please consider recommended updates (css, changeset, test)
|
|
||
| return ( | ||
| <div | ||
| <span |
There was a problem hiding this comment.
the intention is great 👍
some deeper checks are needed, as it can get messy pretty quick.
please check the span targets in css, that were not affected before the change, i.e. in the InputWrapper:
.wrapper span:first-of-type {
max-width: 100%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
if the icon is present there, it will be affected.
this may also have a waterfall effect - i.e. for the apps that do use html targeting, this change will be breaking. not a reason to avoid the change, just note that it is visually breaking for such cases.
side note - raw html elements should not be targeted, exactly for this reason :) we should use classnames; if there's an exception then a comment is mandatory, yet it's not a perfect guardrail.
other thing - would be great to have a regression test for this small update.
There was a problem hiding this comment.
thanks, the concerns are addressed:
- added a changeset note about html targeting
- added a regression test
- tested manually that the span targeting selectors
.wrapper span:first-of-typeand.select-trigger span:first-of-typeare not affected- opened a follow-up issue Replace fragile bare-
spantruncation selectors in InputWrapper and Select with class-based targeting #1303 to update the selectors to use class names
- opened a follow-up issue Replace fragile bare-
Add a regression test that renders an Icon inside a <p> and asserts the wrapper is a span with no React validateDOMNesting warning, so a revert to <div> is caught here. Note the div->span element change in the changeset for consumers that target the wrapper by tag name. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Storybook Preview Deployed✅ Preview URL: https://click-bue0x56ld-clickhouse.vercel.app Built from commit: |
Chromatic Storybook
Built from commit: Statuses as of the end of the run. The build link shows the live review state. |
Description
Iconrendered its SVG inside a block<div>wrapper. Because an icon is inline content, using it inline — e.g. an icon insideText(a<p>), or aLinkwith aniconprop (an<a>) — produced invalid DOM nesting (<div>as a descendant of<p>/<a>) and ReactvalidateDOMNestingwarnings.IconSVG wrapper from<div>to<span>.<span>is phrasing content and legal inline..svg-wrapperis alreadydisplay: flex, so a<span>renders identically — the change is visually neutral and behaviorally pure.role="img"/aria-labelare spread onto the inner SVG (not the wrapper), so the wrapper is purely presentational andgetByRole('img')is unaffected.Links and tickets
Good to know
Rationale: an icon is inline content; a block
<div>wrapper breaks valid nesting wherever an icon is placed inline.span+display: flexkeeps layout identical.Checklist
A
patchchangeset is included. No visual change.Contribution
buildandbuild-storybookwork locallyVerified locally:
typecheck,lint(0 errors),format,circular-dependency:check,test(881/881),build+ health check,storybook:buildall pass. Visual regression in Docker: Icon spec 37/37 and the consumer specs that@covers src/components/Icon(iconbutton, popover, codeblock, genericmenu) 72/72 pass with zero snapshot diffs — no snapshots regenerated.Accessibility
Behavior and ARIA are unchanged (purely a wrapper-element swap). The icon's accessible name still comes from
aria-labelon the SVG, confirmed by the existing unit and visual tests.getByRole('img')tests pass)Screenshots
No visual change — all existing light/dark snapshots match with zero diffs.
🤖 Generated with Claude Code
Note
Low Risk
Presentational wrapper tag change only; styles and ARIA on the inner SVG are unchanged, with a minor caveat for tag-based CSS or DOM assertions.
Overview
Changes the
IconSVG wrapper from a block<div>to an inline<span>so icons nested inside phrasing content (e.g.Text/<p>orLink/<a>) no longer violate DOM nesting rules or trigger ReactvalidateDOMNestingconsole.error warnings. Styling stays on the existing.svg-wrapperclasses withdisplay: flex, so appearance and layout should be unchanged.Adds a regression test that renders an icon inside a
<p>, asserts the wrapper isSPAN, and confirms no console errors. A patch changeset documents the element swap and notes that consumers selecting the wrapper by tag name may need to update those selectors.Reviewed by Cursor Bugbot for commit 613aadd. Bugbot is set up for automated code reviews on this repo. Configure here.