You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You should see a checkbox and a button. Clicking the checkbox should always make the checkbox checked, clicking the button should toggle the state of the checkbox. In practice, the checkbox state is initialized to the value of is_checked on it's initial mount, but is then toggled on click regardless of the value of is_checked. However, the button will correctly update the checkbox to the value of is_checked.
Adding the prevent_default: "onclick" attribute to the input element will prevent any visual changes from happening to the checkbox when clicked...clicking a checked checkbox remains checked, clicking an unchecked checkbox remains unchecked. The button still correctly resets the state correctly.
Environment:
Dioxus version: 0.4.3
Rust version: 1.75.0
OS info: Linux
App platform: web
Questionnaire
I'm interested in fixing this myself but don't know where to start
I would like to fix and I have a solution
I don't have time to fix this right now, but maybe later
The text was updated successfully, but these errors were encountered:
SolidJS has a similar behavior - attempting to control a checkbox like this does not fit with the one-way dataflow paradigm we encourage. In Dioxus we force a re-render since we don't compare values with set, but the bugged behavior remains.
I don't think we can fix this without special casing "checked" checks.
Problem
I'm trying to make a controlled checkbox, and I can't always seem to control the value of the input element with the
checked
attribute.Steps To Reproduce
Here's an extremely contrived but fairly minimum reproducer:
run this with
dx serve
.Expected behavior
You should see a checkbox and a button. Clicking the checkbox should always make the checkbox checked, clicking the button should toggle the state of the checkbox. In practice, the checkbox state is initialized to the value of is_checked on it's initial mount, but is then toggled on click regardless of the value of
is_checked
. However, the button will correctly update the checkbox to the value ofis_checked
.Adding the
prevent_default: "onclick"
attribute to theinput
element will prevent any visual changes from happening to the checkbox when clicked...clicking a checked checkbox remains checked, clicking an unchecked checkbox remains unchecked. The button still correctly resets the state correctly.Environment:
Questionnaire
The text was updated successfully, but these errors were encountered: