feat: add scroll to 0 for web router

This commit is contained in:
Jonathan Kelley 2022-12-13 15:00:54 -08:00
parent 5c20e651da
commit 7e45f2aa04

View file

@ -126,6 +126,11 @@ pub fn Link<'a>(cx: Scope<'a, LinkProps<'a>>) -> Element {
if let Some(service) = svc { if let Some(service) = svc {
log::trace!("Pushing route to {}", to); log::trace!("Pushing route to {}", to);
service.push_route(to, cx.props.title.map(|f| f.to_string()), None); 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 { } else {
log::error!( log::error!(
"Attempted to create a Link to {} outside of a Router context", cx.props "Attempted to create a Link to {} outside of a Router context", cx.props