From 893822eadecb8b79d8b5fac629d98faff46ecbd3 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Wed, 11 Dec 2024 08:39:11 -0600 Subject: [PATCH 1/2] Fix liveview links --- packages/liveview/src/history.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/liveview/src/history.rs b/packages/liveview/src/history.rs index 7009ed58be..aed8fcfc7f 100644 --- a/packages/liveview/src/history.rs +++ b/packages/liveview/src/history.rs @@ -342,6 +342,10 @@ impl History for LiveviewHistory { let mut updater_callback = self.updater_callback.write().unwrap(); *updater_callback = callback; } + + fn include_prevent_default(&self) -> bool { + true + } } mod routes { From 5803a72ec770cb0f9753466fc76e96dcee87d842 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Wed, 11 Dec 2024 08:53:10 -0600 Subject: [PATCH 2/2] Serve all routes under with_virtual_dom --- packages/liveview/src/adapters/axum_adapter.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/liveview/src/adapters/axum_adapter.rs b/packages/liveview/src/adapters/axum_adapter.rs index 638e6cd9cf..4e819d512a 100644 --- a/packages/liveview/src/adapters/axum_adapter.rs +++ b/packages/liveview/src/adapters/axum_adapter.rs @@ -62,6 +62,13 @@ impl LiveviewRouter for Router { }; let app = Arc::new(app); + // Add an extra catch all segment to the route + let mut route = route.trim_matches('/').to_string(); + if route.is_empty() { + route = "/*route".to_string(); + } else { + route = format!("/{route}/*route"); + } self.route( &ws_path, @@ -75,7 +82,7 @@ impl LiveviewRouter for Router { }), ) .route( - route, + &route, get(move || async move { index_page_with_glue(&interpreter_glue(&ws_path)) }), ) }