From a0b4cc51f326c2a553aeabae83d5acb0976426d9 Mon Sep 17 00:00:00 2001 From: Bradford Hovinen Date: Wed, 1 Jul 2026 20:40:39 +0200 Subject: [PATCH] native-dom: Add a way to generate synthetic click events This is needed for the new dioxus testing library. Tests need a way to interact with the the system under test -- in this case, to tell them that the user has clicked a component. Previously there was no way to construct the required `NativePointerData` struct outside the native-dom crate itself. --- packages/native-dom/src/events.rs | 6 ++++++ packages/native-dom/src/lib.rs | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/native-dom/src/events.rs b/packages/native-dom/src/events.rs index b1bc312d3e..7278562646 100644 --- a/packages/native-dom/src/events.rs +++ b/packages/native-dom/src/events.rs @@ -518,3 +518,9 @@ impl InteractionLocation for NativeWheelData { PagePoint::new(self.0.page_x() as f64, self.0.page_y() as f64) } } + +pub fn synthetic_click_event(node: &Node, modifiers: Modifiers) -> Box { + Box::new(NativePointerData( + node.synthetic_click_event_data(modifiers), + )) +} diff --git a/packages/native-dom/src/lib.rs b/packages/native-dom/src/lib.rs index e7374a90c3..e2b044e9f0 100644 --- a/packages/native-dom/src/lib.rs +++ b/packages/native-dom/src/lib.rs @@ -15,7 +15,7 @@ mod mutation_writer; mod write_once_attr; pub use blitz_dom::DocumentConfig; pub use dioxus_document::DioxusDocument; -pub use events::NodeHandle; +pub use events::{NodeHandle, synthetic_click_event}; pub use write_once_attr::{CustomWidgetAttr, SubDocumentAttr}; use blitz_dom::{LocalName, Namespace, QualName, ns};