Skip to content

fix(switch): selected state is updated during input event #5501

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

Merged

Conversation

vdegenne
Copy link
Contributor

Fixes #5486

@asyncLiz
Copy link
Collaborator

This is intentional, the selected attribute represents the default state of the form control, not its current active state. This matches <input type="checkbox" checked> behavior, whether the checked attribute does not change when the value changes.

#5486 should be fixed by changing the switch to update its state on 'input' instead of 'change', similar to checkbox.

@vdegenne
Copy link
Contributor Author

@asyncLiz Sorry to tag you but I couldn't request a review you were not automatically placed in the reviewers list.

That should do it

@asyncLiz asyncLiz changed the title fix(switch): reflect selected state in input event fix(switch): selected state is updated during input event Mar 11, 2024
Copy link
Collaborator

@asyncLiz asyncLiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@copybara-service copybara-service bot merged commit 2ae226c into material-components:main Mar 12, 2024
@vdegenne vdegenne deleted the switch-input-event branch March 12, 2024 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch misses input event handler
2 participants