You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
i ran into issue when styling radio group items with the new :has css styling.
i have a css like this
// sets interactive color if element is checked// aria checked attribute is necessary if component is used without a form&:has(*[checked="true"]):not(:has(*:disabled)),&:has(*[data-state="checked"]):not(:has(*:disabled)){background-color: red;}
if i switch between two radio button and then switch routes and go back via back button, both radio input are getting the style even though only one input radio has the attribute checked in the web inspector.
But if i select the items via the browser console, the "unchecked" radio item still hast checked true on the element.
After a little bit of digging it seems that setting the checked attribute is not the valid way.
The presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value.
If the attribute is present, its value must either be the empty string or a value that is an ASCII case-insensitive match for the attribute's canonical name, with no leading or trailing whitespace.
change the way of setting the attribute on the input radio
{isFormControl&&(<BubbleInputcontrol={button}bubbles={!hasConsumerStoppedPropagationRef.current}name={name}value={value}// only set attribute 'checked' if true to checked="checked"// if false don't render attribute completelychecked={checked ? "checked" : undefined}required={required}disabled={disabled}// We transform because the input is absolutely positioned but we have// rendered it **after** the button. This pulls it back to sit on top// of the button.style={{transform: 'translateX(-100%)'}}/>)}
Hi,
i ran into issue when styling radio group items with the new :has css styling.
i have a css like this
if i switch between two radio button and then switch routes and go back via back button, both radio input are getting the style even though only one input radio has the attribute checked in the web inspector.
But if i select the items via the browser console, the "unchecked" radio item still hast checked true on the element.
After a little bit of digging it seems that setting the checked attribute is not the valid way.
https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes
Here is the code in your primitive.
primitives/packages/react/radio-group/src/Radio.tsx
Line 80 in 6469d41
I guess it would be better to
or
This is maybe also the case for checkboxes
primitives/packages/react/checkbox/src/Checkbox.tsx
Line 108 in 6469d41
The text was updated successfully, but these errors were encountered: