Skip to content
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

RadioGroup.Item and RadioCards.Item accept checked prop #451

Open
kevinmitch14 opened this issue Apr 10, 2024 · 2 comments
Open

RadioGroup.Item and RadioCards.Item accept checked prop #451

kevinmitch14 opened this issue Apr 10, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@kevinmitch14
Copy link

I noticed that CheckboxCards.Item and CheckboxGroup.Item don't accept checked as a prop. Is this by design? RadioGroup and RadioCards seem to accept this, along with Checkbox.

Screenshot 2024-04-10 at 13 55 06
@kevinmitch14 kevinmitch14 changed the title CheckboxCards and CheckboxGroup don't accept checked prop CheckboxCards and CheckboxGroup don't accept checked prop Apr 10, 2024
@vladmoroz
Copy link
Contributor

vladmoroz commented Apr 10, 2024

Yes, the value prop on the Root part is the source of truth. I'll double check the Radio Group and Radio Cards, don't think those should have the checked prop

@kevinmitch14
Copy link
Author

kevinmitch14 commented Apr 10, 2024

Gotcha, in my case we are using them as a sort of stepper. So if step1 is completed, the CheckboxCards.Root value should have "step1" in it and so on.

But I can't do the following: step1Completed can be string | undefined and you can't assign undefined to string.

// Type 'string | undefined' is not assignable to type 'string'.
<CheckboxCards.Root value={[step1Completed && "step1", step2Completed && "step2"]}>

So I am doing the following to keep typescript happy but it seems like a hacky solution:

<CheckboxCards.Root value={[step1Completed ? "step1": "_", step2Completed ? "step2": "_"]}>

Edit: I'm prob not going to continue using this method, but just thought I would raise it here.

@vladmoroz vladmoroz changed the title CheckboxCards and CheckboxGroup don't accept checked prop RadioGroup.Item and RadioCards.Item accept checked prop Apr 11, 2024
@vladmoroz vladmoroz added the bug Something isn't working label Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants