Skip to content

fix(badge): render the Badge.Container cutout outside of strict mode - #706

Merged
blvdmitry merged 2 commits into
mainfrom
claude/dreamy-lamport-6i1gg2
Nov 8, 2026
Merged

blvdmitry merged 2 commits into
mainfrom
claude/dreamy-lamport-6i1gg2

Conversation

@blvdmitry

@blvdmitry blvdmitry commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The cutout from #700 never showed up in apps that don't use React strict mode: --rs-badge-width/--rs-badge-height were never set.

On mount, React runs a child's layout effects before it attaches the parent's ref. Badge's effect read containerRef.current from Badge.Container right away, got null, and returned without creating the ResizeObserver. Strict mode hid this because it runs effects a second time, after the ref is attached. Storybook renders stories in strict mode.

The fix reads the container ref inside the ResizeObserver callback. That callback runs after the commit, so the ref is always set by then.

Related Issue

Follow-up to #700.

Screenshots / Recordings

—

Notes for Reviewers

  • I verified the fix with a story test that renders into a root without strict mode: it failed before the fix and passed after. The test isn't committed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TKGZMiUmdStWLExYVEEWcT

…t renders outside of strict mode

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKGZMiUmdStWLExYVEEWcT
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Library / JS 52.73 KB (0%) 1.1 s (0%) 0 ms (+100% 🔺) 1.1 s
Library / CSS 24.57 KB (0%) 492 ms (0%) 0 ms (+100% 🔺) 492 ms
Theming / JS 7.8 KB (0%) 156 ms (0%) 259 ms (-24.81% 🔽) 415 ms
Theming with a default theme definition / JS 8.68 KB (0%) 174 ms (0%) 709 ms (+83.57% 🔺) 883 ms

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKGZMiUmdStWLExYVEEWcT
@blvdmitry
blvdmitry merged commit b69f1eb into main Nov 8, 2026
11 checks passed
@blvdmitry
blvdmitry deleted the claude/dreamy-lamport-6i1gg2 branch November 8, 2026 23:50
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.

2 participants