Description
Bug report
Current Behavior
https://www.loom.com/share/e32cb8f4c23246aaa8314c80c31a5a07
basically the invisible hidden checkbox that comes with the switch button, in the case that it is a form control (automatically determined by the switch being inside a form it seems), causes our page scrolling to go haywire because it gets rendered way off to the bottom of the actual page content.
eyeballing the code it seems to render the switch button UI and the hidden checkbox input next to each other without a common parent, and so it's absolutely positioned relative to whatever context it's in, which doesn't generally make sense IMO. there's no common parent to control what it's absolutely positioned relative to.
Expected behavior
Switch don't cause the page scroll area to expand beyond the bounds of the switch itself, regardless of the circumstances where it's being used
Reproducible example
CodeSandbox Template
Will do when I get a chance.
Suggested solution
Ideally not randomly absolutely position this thing?
Additional context
Looks like this is the area where the problems are coming in: https://github.com/radix-ui/primitives/blob/79304015e13a31bc465545fa1d20e743a0bce3c5/packages/react/switch/src/switch.tsx#L96C27-L96C50
Your environment
Software | Name(s) | Version |
---|---|---|
Radix Package(s) | switch | 1.1.2 |
React | n/a | 19 |
Browser | Arc | 1.97.0 |
Assistive tech | ||
Node | n/a | 22 |
npm/yarn/pnpm | pnpm | |
Operating System | macOS | Sequoia |