-
Notifications
You must be signed in to change notification settings - Fork 879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[labs/react] boolean attributes should allow false to be more react-like #3053
Comments
I've been looking into workarounds on our side some more and it looks like React will actually handle this properly in React 19 once they release the proper web component support. They have a merged PR, behind the experimental flag, that will convert |
This is a good thing for us to do to match the behavior of React 19's WC support. |
I'd imaging something similar with |
In our case, the issue was that we had a CSS selector on But the "false" string value doesn't follow the convention of the |
It seems the workaround listed here doesn't work either. I've also tried |
Hey @ashleyryan @mjaggard! We have updates! We've updated how we apply react props onto web components inside the wrapper. Properties like |
Want to confirm that boolean properties like However there are other attributes which are not boolean that take boolean values like There are several other properties with However #3128 moves the web component wrapper much closer to react behavior than before. |
Thanks for this @taylor-vann - I no longer work on the project that was having the issue, but I'll pass it on to the team. I did clone the repo and checked it out really quick and it most of the jest tests have passed as expected when I remove the higher order component I build to convert false to undefined. One is failing still and I haven't had a chance to dig into it yet, but it looks good for the most part! |
@ashleyryan All but one test? I'll take that hahah nice :) Very curious about the last test. |
Figured it out! It was an async timing issue where I was checking for the hidden attribute before the first render was finished. It passes, looks like our workaround can safely be removed. Thanks for fixing this! I should note that I only had this issue with the |
Thanks so much @ashleyryan for the extra help, I really appreciate it. Im going to mark this issue as resolved from #3128 |
Description
A boolean attribute, by definition, is true when it exists on the element, regardless of the value. There is no
hidden="false"
, the false value would be removing the attribute. React allows false values for things likechecked
, so it's confusing to have to do something likehidden={showElement ? undefined : true}
on a boolean attribute.We have this issue on our Modals.
Steps to Reproduce
set
hidden={false}
on a CdsModal and notice that it does not show, as expected.Live Reproduction Link
https://stackblitz.com/edit/clarity-react-8em3m2?file=src%2FApp.tsx
Expected Results
The
hidden
prop can accept a value of false and behave likeundefined.
Actual Results
false
is the same astrue
Browsers Affected
The text was updated successfully, but these errors were encountered: