From 7e45f2aa049117c0c24dcd6b4cb2917c48b52fa9 Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Tue, 13 Dec 2022 15:00:54 -0800 Subject: [PATCH] feat: add scroll to 0 for web router --- packages/router/src/components/link.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/router/src/components/link.rs b/packages/router/src/components/link.rs index 35268e94d..d077966eb 100644 --- a/packages/router/src/components/link.rs +++ b/packages/router/src/components/link.rs @@ -126,6 +126,11 @@ pub fn Link<'a>(cx: Scope<'a, LinkProps<'a>>) -> Element { if let Some(service) = svc { log::trace!("Pushing route to {}", to); service.push_route(to, cx.props.title.map(|f| f.to_string()), None); + + #[cfg(feature = "web")] + { + web_sys::window().unwrap().scroll_to_with_x_and_y(0.0, 0.0); + } } else { log::error!( "Attempted to create a Link to {} outside of a Router context", cx.props