-
Notifications
You must be signed in to change notification settings - Fork 20
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: toggle default value #395
base: main
Are you sure you want to change the base?
Conversation
} | ||
None => view! { <Toggle value=false on_change class name/> }.into_view(), | ||
None => { | ||
on_change.call(Value::Bool(false)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would get triggered on every re-render
this should be dealt at the moment when the type is being chosen by the user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
} | ||
None => view! { <Toggle value=false on_change class name/> }.into_view(), | ||
None => { | ||
on_change.call(Value::Bool(false)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
cee4169
to
612a44c
Compare
612a44c
to
ee8e36b
Compare
@@ -278,6 +278,9 @@ where | |||
) { | |||
(Ok(schema_type), Ok(enum_variants)) => { | |||
let input_type = InputType::from((schema_type.clone(), enum_variants)); | |||
if input_type == InputType::Toggle { | |||
config_value_ws.set(Value::Bool(false)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is also at render time
Problem
The toggle component defaults to null instead of a boolean value when initially rendered, causing unexpected behavior until user interaction occurs.
Solution
Called the onChange event handler to properly handle the initial null state, ensuring the toggle always has a valid boolean value (true/false).