Synchronous prevent default (#2792)
* add prevent default methods to the event * sync prevent default almost working * sync prevent default working * Move event handling into the runtime * update core tests * restore desktop file dialog * implement prevent default on web * add a hint about the new prevent default method * fix web prevent default * Fix CTRL+click on links * fix values memorize in place test * Fix a few more tests * Add a playwright test for sync prevent default * Fix core doc tests * create a deprecated VirtualDom::handle_event * fix macos imports in desktop * Fix onmounted event * Fix liveview support * switch to RefCell for metadata * Remove println * remove prevent default attribute * remove web specific link behavior * Fix liveview links * more liveview fixes for link * Fix merge conflicts * Fix clippy * use the new prevent default in the file upload example
This commit is contained in:
1 parent
8b62b71e2d
commit
cab573eefd
54 files changed
+940
-729
No files matched your search
@@ -94,4 +94,16 @@ test("eval", async ({ page }) => {
|
||||
await expect(div).toHaveText("returned eval value");
|
||||
});
|
||||
|
||||
// Shutdown the li
|
||||
test("prevent default", async ({ page }) => {
|
||||
await page.goto("http://localhost:9999");
|
||||
|
||||
// Expect the page to contain the div with the eval and have no text.
|
||||
const a = page.locator("a.prevent-default");
|
||||
await expect(a).toHaveText("View source");
|
||||
|
||||
// Click the <a> element to change the text
|
||||
await a.click();
|
||||
|
||||
// Check that the <a> element changed.
|
||||
await expect(a).toHaveText("Psych!");
|
||||
});
|
||||
@@ -51,6 +51,23 @@ fn app() -> Element {
|
||||
"Eval"
|
||||
}
|
||||
div { class: "eval-result", "{eval_result}" }
|
||||
PreventDefault {}
|
||||
}
|
||||
}
|
||||
|
||||
#[component]
|
||||
fn PreventDefault() -> Element {
|
||||
let mut text = use_signal(|| "View source".to_string());
|
||||
rsx! {
|
||||
a {
|
||||
class: "prevent-default",
|
||||
href: "https://github.com/DioxusLabs/dioxus/tree/main/packages/playwright-tests/web",
|
||||
onclick: move |evt| {
|
||||
evt.prevent_default();
|
||||
text.set("Psych!".to_string());
|
||||
},
|
||||
"{text}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user