-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
prevent_default
is not respected after bubbling events
#1662
Comments
The simple routes example in the router package appears to work correctly in liveview. Do you have the dioxus-router = { git = "https://github.com/DioxusLabs/dioxus", features = "liveview" } |
I do! I have a workspace setup, but the result should be the same:
and in the root:
|
I managed to find what triggered the error. I wanted to style my links, so I went and did this:
Removing the inner div makes it work perfectly (losing the styling, though). |
Adding |
prevent_default
and as a result is treated as an external linkprevent_default
is not respected after bubbling events
Ok, so the larger issue here is that prevent default is taken from the element that the event originated in, but not when bubbling the event. Here is a minimal example of that bug: use dioxus::prelude::*;
fn main() {
dioxus_desktop::launch(app);
}
fn app(cx: Scope) -> Element {
let mut count = use_state(cx, || 0);
cx.render(rsx! {
a {
href: "http://example.com",
prevent_default: "onclick",
div {
"click me"
}
}
})
} |
Problem
In Liveview,
prevent_default
on the Link component does not work:dioxus/packages/router/src/components/link.rs
Line 248 in d9220d4
As a result, the link treats every route, internal or external, as an external link and the page reloads upon redirect.
Steps To Reproduce
Set up a router and Links in Liveview.
Example:
Expected behavior
A Link to an internal route should be treated as an internal route. The expected behavior can be simulated by commenting out this line:
dioxus/packages/router/src/components/link.rs
Line 247 in d9220d4
Screenshots
N/A
Environment:
master
Questionnaire
The text was updated successfully, but these errors were encountered: