-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix: toggle default value #395
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
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
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.
pending comment
@@ -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.
pending comment
ee8e36b
to
8b1bf63
Compare
if let (Ok(schema_type), Ok(enum_variants)) = ( | ||
SchemaType::try_from(config_schema_rs.get()), | ||
EnumVariants::try_from(config_schema_rs.get()), | ||
) { | ||
if InputType::from((schema_type, enum_variants)) |
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.
are we not going to store it to optimise the repeated computations ?
8b1bf63
to
ad4f9e4
Compare
ad4f9e4
to
3c16c72
Compare
schema_type_ws | ||
.set(SchemaType::try_from(type_schema.clone())); | ||
enum_variants_ws.set(EnumVariants::try_from(type_schema)); |
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.
can we rather store in local variable and then set and then use the local variable in the subsequent lines
schema_type_ws | ||
.set(SchemaType::try_from(type_schema.clone())); | ||
enum_variants_ws.set(EnumVariants::try_from(type_schema)); | ||
if let (Ok(schema_type), Ok(enum_variants)) = ( | ||
schema_type_rs.get(), | ||
enum_variants_rs.get(), | ||
) { |
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.
Please assign the value of schema type and enum variants to some variable and then use it set the signal and the if check.
Please refrain from setting the signal and then immediately reading from it.
3c16c72
to
fa15502
Compare
Comments were resolved. Please review again
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).