-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Inappropriate behavior in button's onclick event #3097
Comments
Maybe the same issue as #3094 |
@chungwong |
Take a close look at the code. You use this part twice #![allow(non_snake_case)]
use dioxus::prelude::*;
use dioxus_logger::tracing;
#[derive(Clone, Routable, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
enum Route {
#[route("/")]
Home {},
}
#![allow(non_snake_case)]
use dioxus::prelude::*;
use dioxus_logger::tracing;
#[derive(Clone, Routable, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
enum Route {
#[route("/")]
Home {},
} It works fine for me Dioxus.toml [dependencies]
dioxus = { git = "https://github.com/DioxusLabs/dioxus", features = ["router"] }
dioxus-logger = "0.5.1"
serde = { version = "1.0.213", features = ["derive"] }
[features]
web = ["dioxus/web"] Code
bandicam.2024-10-25.20-44-17-867.mp4 |
@RustGrow Ok, I will close and test it. Thank you! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem
When using a for loop to draw the UI and create a structure that places a button underneath from dioxus-cli 0.6.0-alpha.3, The button's onclick event points to the second element of the for statement, not the button.
Steps To Reproduce
Steps to reproduce the behavior:
Expected behavior
onclick event is normally attached to the button
Screenshots
No event occurs when the button is clicked.
When option 2 is clicked, a click event is unintentionally triggered and a log is recorded.
https://github.com/user-attachments/assets/72ae348d-b811-411e-b0db-84df3c4e0b5d
Environment:
Questionnaire
That part is part of my code.
If I try to render that function as a conditional statement, and use a for loop to create the element and add a button below that part, the onclick event doesn't work properly.
It looks like the onclick event is not attached to the button, but to the second element in the for loop.
Wrapping the entire for loop in a div or removing the conditional seemed to work fine.
I'm raising this as an issue ticket because I'm curious as to whether that part was intentional.
The text was updated successfully, but these errors were encountered: