fix(AspectRatio): match Radix primitive structure for DOM parity#2027
Draft
maxffarrell wants to merge 1 commit intohuntabyte:mainfrom
Draft
fix(AspectRatio): match Radix primitive structure for DOM parity#2027maxffarrell wants to merge 1 commit intohuntabyte:mainfrom
maxffarrell wants to merge 1 commit intohuntabyte:mainfrom
Conversation
Move wrapper styles (position: relative, width, padding-bottom) onto the root props so user-provided class/style/ref attach to the outer container div — matching the @radix-ui/react-aspect-ratio source exactly. The inner div now has hardcoded `position: absolute; inset: 0` via style: directives rather than being user-accessible, matching Radix's inner Primitive.div which only ever carries the absolute-positioning styles. Sources: - https://github.com/radix-ui/primitives/blob/main/packages/react/aspect-ratio/src/aspect-ratio.tsx Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Contributor
built with Refined Cloudflare Pages Action⚡ Cloudflare Pages Deployment
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
position: relative,width: 100%,padding-bottom) from hard-codedstyle:directives intorootState.propsso that they are merged with user-provided props viamergeProps<div>now receivesmergedProps— meaningclass,style,ref, and all HTML attributes the user passes attach to the outer container, matching the Radix primitive exactly<div>is now a pure implementation detail with hard-codedstyle:position="absolute" style:inset="0"and no user-accessible propsMotivation
The
@radix-ui/react-aspect-ratiosource renders two divs:Source: https://github.com/radix-ui/primitives/blob/main/packages/react/aspect-ratio/src/aspect-ratio.tsx
Before this change, bits-ui applied user props to the inner div and hard-coded the wrapper styles on the outer div with
style:directives. This meantclass="overflow-hidden rounded-xl"would clip the inner absolute-positioned box instead of the outer padded wrapper — a subtle but observable difference from the React primitive.Test plan
<AspectRatio.Root ratio={16/9} class="overflow-hidden rounded-xl">— border-radius and overflow clipping apply to the outer wrapper ✓refbinds to the outer container element ✓stylepassed by the user merges with (and can extend) the wrapper styles ✓svelte-checkpasses with 0 errors ✓🤖 Generated with Claude Code