From 874a1bf495d778a9ac6bc1c16e8034e5adb511ee Mon Sep 17 00:00:00 2001 From: jacobshandling <61553566+jacobshandling@users.noreply.github.com> Date: Mon, 9 Dec 2024 12:21:36 -0800 Subject: [PATCH] =?UTF-8?q?UI=20=E2=80=93=20Restore=20user's=20current=20s?= =?UTF-8?q?croll=20after=20updating=20the=20host=20software=20filter=20(#2?= =?UTF-8?q?4455)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## #23095 https://github.com/user-attachments/assets/90640987-e06f-432c-9fd2-765753ac1d73 - [x] Changes file added for user-visible changes in `changes/` - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling --- changes/23095-host-sw-scroll | 1 + .../cards/Software/HostSoftwareTable/HostSoftwareTable.tsx | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 changes/23095-host-sw-scroll diff --git a/changes/23095-host-sw-scroll b/changes/23095-host-sw-scroll new file mode 100644 index 0000000000..6788c9f511 --- /dev/null +++ b/changes/23095-host-sw-scroll @@ -0,0 +1 @@ +- Restore the user's previous scroll, if any, when they change the filter on the host software table. diff --git a/frontend/pages/hosts/details/cards/Software/HostSoftwareTable/HostSoftwareTable.tsx b/frontend/pages/hosts/details/cards/Software/HostSoftwareTable/HostSoftwareTable.tsx index d601141631..ca03de966e 100644 --- a/frontend/pages/hosts/details/cards/Software/HostSoftwareTable/HostSoftwareTable.tsx +++ b/frontend/pages/hosts/details/cards/Software/HostSoftwareTable/HostSoftwareTable.tsx @@ -102,6 +102,13 @@ const HostSoftwareTable = ({ routeTemplate, queryParams: newParams, }); + const prevYScroll = window.scrollY; + setTimeout(() => { + window.scroll({ + top: prevYScroll, + behavior: "smooth", + }); + }, 0); router.replace(nextPath); }, [pathPrefix, routeTemplate, router, searchQuery, sortDirection, sortHeader]