From 3aa0144e8db49096dff1da83d95eececa430fdcd Mon Sep 17 00:00:00 2001 From: Bill Thiede Date: Wed, 26 Feb 2025 15:42:51 -0800 Subject: [PATCH] web: try setting history.scroll_restoration to manual to impove inter-page flow --- web/Cargo.toml | 2 ++ web/src/state.rs | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/web/Cargo.toml b/web/Cargo.toml index b8e4630..9cb184f 100644 --- a/web/Cargo.toml +++ b/web/Cargo.toml @@ -50,4 +50,6 @@ features = [ "MediaQueryList", "Navigator", "Window", + "History", + "ScrollRestoration", ] diff --git a/web/src/state.rs b/web/src/state.rs index 917be0c..8247b85 100644 --- a/web/src/state.rs +++ b/web/src/state.rs @@ -29,6 +29,12 @@ pub fn unread_query() -> &'static str { pub fn init(url: Url, orders: &mut impl Orders) -> Model { let version = letterbox_shared::build_version(bi); info!("Build Info: {}", version); + // Disable restoring to scroll position when navigating + window() + .history() + .expect("couldn't get history") + .set_scroll_restoration(web_sys::ScrollRestoration::Manual) + .expect("failed to set scroll restoration to manual"); if url.hash().is_none() { orders.request_url(urls::search(unread_query(), 0)); } else {