gioser

tawasuyu/brahman

Rust 582TOML 222Markdown 73JSON 198635 Definitions

gioser-web: fix graph node click callback, dispatch MouseEvent on tip

- Graph callback now creates a web_sys::MouseEvent('click') and
  dispatches it on the corresponding .tip element.
- The existing install_tip_clicks listener captures it and calls
  open_or_switch with proper coordinates.

03815857458b57bb00a5fe2579313e638a75c552 · by Sergio · (5 months ago) · parent dac1fc71a · browse the tree at this commit

Semantic delta · 1

crates/apps/gioser-web/src/lib.rs

2 files · +7 −7

diff --git a/crates/apps/gioser-web/pkg/gioser_web_bg.wasm b/crates/apps/gioser-web/pkg/gioser_web_bg.wasm
index 45c7ee6..6dc08de 100644
Binary files a/crates/apps/gioser-web/pkg/gioser_web_bg.wasm and b/crates/apps/gioser-web/pkg/gioser_web_bg.wasm differ
diff --git a/crates/apps/gioser-web/src/lib.rs b/crates/apps/gioser-web/src/lib.rs
index edc8c3f..c84867e 100644
--- a/crates/apps/gioser-web/src/lib.rs
+++ b/crates/apps/gioser-web/src/lib.rs
@@ -357,8 +357,7 @@ impl AppState {
             );
             wrapper.append_child(&label).ok();
             content_clone.append_child(&wrapper).ok();
-            // Callback: recibe 'camino' del nodo clickeado y dispara click
-            // en el tip correspondiente (simula apertura de página)
+            // Callback: recibe 'camino' del nodo clickeado y navega
             let cb: Box<dyn FnMut(String)> = Box::new(move |target| {
                 // Mapa camino → elemento HTML
                 let el = match target.as_str() {
@@ -368,14 +367,15 @@ impl AppState {
                     "uku" | "agua" => "uku",
                     _ => "logos",
                 };
+                // Disparar evento click en el tip (el listener de
+                // install_tip_clicks lo captura y llama open_or_switch)
                 if let Some(tip) = document_clone.query_selector(
                     &format!(".tip[data-md][id='tip-{}']", el)
                 ).ok().flatten() {
-                    // Simular click real en el tip — la animación de
-                    // expansión la maneja AppState::open_or_switch
-                    let _ = tip.dispatch_event(
-                        &web_sys::MouseEvent::new("click").unwrap()
-                    );
+                    // Crear MouseEvent con coordenadas (necesario para
+                    // que prevent_default y open_or_switch tengan contexto)
+                    let ev = web_sys::MouseEvent::new("click").unwrap();
+                    let _ = tip.dispatch_event(&ev);
                 }
             });
             let mut graph = GraphWidget::new(