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

fix: events and checked prop in Radio #426

Merged
merged 6 commits into from
Jun 29, 2021
Merged

fix: events and checked prop in Radio #426

merged 6 commits into from
Jun 29, 2021

Conversation

acstll
Copy link
Collaborator

@acstll acstll commented Jun 25, 2021

With the current radio button implementation, the scaleChange event is being fired only once. This makes it impossible to hook with framework's state/models.

This PR fixes that.

(It also fixes the click event being fired twice while clicking on the label.)

Why

input[type="radio"] elements only fire change events after user input and only when being actually checked, not unchecked (there is no change event while being unchecked). Since our component relies on this change event to update its checked property, this remains true forever after the first change event. And, since the scaleChange event gets fired using a watcher on this same checked prop, it fires only once: the one time checked changes from false to true.


Some inspiration: https://github.com/shoelace-style/shoelace/blob/next/src/components/radio/radio.ts

@acstll acstll added the bug Something isn't working label Jun 25, 2021
@acstll acstll self-assigned this Jun 25, 2021
@acstll acstll requested a review from eeegor as a code owner June 25, 2021 08:23
@acstll acstll merged commit c9e780c into main Jun 29, 2021
@acstll acstll deleted the fix/broken-radio-button branch June 29, 2021 07:19
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

Successfully merging this pull request may close these issues.

1 participant