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]