UI – Restore user's current scroll after updating the host software filter (#24455)

## #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 <jacob@fleetdm.com>
This commit is contained in:
jacobshandling 2024-12-09 12:21:36 -08:00 committed by GitHub
parent d47bd8f626
commit 874a1bf495
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 0 deletions

View file

@ -0,0 +1 @@
- Restore the user's previous scroll, if any, when they change the filter on the host software table.

View file

@ -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]