Repository navigation
fix(RadioGroup): forward parent scope id onto RadioGroupItem control (#2751) - #2755
Conversation
…2751) `RadioGroupItem` sets `inheritAttrs: false` and wraps the multi-root `Radio`, so Vue's automatic parent scope-id fallthrough is dropped and a consumer's `<style scoped>` rules never reach the rendered control. Forward the parent scope id via `useForwardScopeId()` so scoped styles apply. `ToggleGroupItem` wraps `Toggle` the same way and had the identical bug, so it gets the same fix. Adds regression tests for both via scoped-style fixtures. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthrough
ChangesScoped Style ID Forwarding for RadioGroupItem and ToggleGroupItem
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
Description
Fixes #2751.
RadioGroupItemsetsinheritAttrs: falseand renders the multi-rootRadio(visible control + sibling hidden form input) as its root. Because of this, Vue's automatic parent scope-id fallthrough is dropped, so when a consumer usesRadioGroupItemas a styled element under<style scoped>, thedata-v-xxxxattribute never lands on the rendered control and the scoped CSS rules don't apply.The fix forwards the parent scope id with the existing
useForwardScopeId()helper (the same approach introduced for the multi-root form controls in #2720) and spreads it onto the innerRadio.Similar case caught
While auditing for the same pattern,
ToggleGroupItemwas found to wrap the multi-rootTogglein exactly the same way and had the identical bug (confirmed failing with a regression test before the fix). It gets the sameuseForwardScopeId()treatment.Other multi-root form controls (
Checkbox,Switch,Toggle,Radio) already forward the scope id, and the remaining*Rootcomponents render their hidden input nested inside a single Primitive root, so they are unaffected.Tests
Added regression tests in
useForwardScopeId.test.tsusing scoped-style fixtures (_ScopedRadioGroup.vue,_ScopedToggleGroup.vue) that assert the parent scope id reaches the control's<button>for bothRadioGroupItemandToggleGroupItem.pnpm --filter reka-ui exec vitest run(affected suites) ✅pnpm lint(0 errors) ✅pnpm --filter reka-ui type-check✅🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests