-
-
Notifications
You must be signed in to change notification settings - Fork 787
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
Added checked state part for radio & radio button #933
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@claviska |
@ErikOnBike The thing is that before beta.80 there was a If you have also a That means if the next version of shoelace will be released instead of writing
you must write
and then it should work. |
@Buni48 thanks for the reply. I must have missed the change log comment about 'checked' no longer being present. Is there a reason why 'checked' on the radio/radio-button is not kept alongside 'value' on the group? Couldn't they co-exist like sl-select has a 'value' and sl-menu-items within it can be 'checked'? If a radio or radio-button is checked (programmatically or by clicking) it could tell its parent/owner (the radio-group) a change is requested. The radio-group could make this happen by de-selecting a previously selected radio or radio-button and selecting the newly requested one (if all validations are okay). This way the group stays in control. |
I think
But you're definitely right that there is an inconsistency with I looked what happens if I try this:
What happens is that the I understand why this happens but I think maybe adding a Your idea that the children (radios etc.) could tell the parent that something changed is also a possible solution but I don't really get the advantage you receive when you can also use a |
I agree that inconsistencies can arise and if that is the reason for choosing this approach, that's okay. (I didn't realise at first it was possible to add the --checked part name dynamically, so it does solve the original issue :-). On a slightly side note: I use Shoelace mostly programmatically. With the new change I can still programmatically get or set the |
Radios are a special case. The radio group is the form control now, not the radios. This differs from HTML in that the radio group handles the value, and the radio items are managed by the radio group. You can't use a radio without a radio group because of this (similar to not being able to use an The radio group manages a radio item's checked state by setting the I'm aware of the inconsistency between this and select. I do plan on revisiting these now that I'll have more time to focus on things like this :) By the way — radio group was reworked to improve accessibility, as screen readers previously weren't announcing the correct number of options. The controller approach solved that. |
For now, a part works so I'm going to merge this since it solves the problem. In the future, I'll be adding more parts for state. In the |
Fixes #931