Skip to content

Commit

Permalink
bugfix for sticky header with expanded filters
Browse files Browse the repository at this point in the history
  • Loading branch information
afwilcox committed Sep 29, 2023
1 parent 28c1f8d commit 5147cea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 15 additions & 1 deletion frontend/src/app/components/containers/complaints/complaints.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,21 @@ export const Complaints: FC<Props> = ({ defaultComplaintType }) => {
<Nav.Item
className="ms-auto"
{...getToggleProps({
onClick: () => setExpanded((prevExpanded) => !prevExpanded),
onClick: () => {
const filterElem = document.querySelector("#collapsible-complaints-list-filter-id");
const rect = filterElem?.getBoundingClientRect();
const bottom = rect?.bottom;

if({isExpanded}.isExpanded && bottom !== undefined && bottom < 140) //page has been scrolled while filter is open... need to close it!
{
setExpanded((prevExpanded) => !prevExpanded);
}
window.scrollTo({
top: 0,
behavior: "smooth",
});
setExpanded((prevExpanded) => !prevExpanded);
},
})}
>
<div
Expand Down
1 change: 1 addition & 0 deletions frontend/src/assets/sass/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
position: sticky !important;
top: 72px; // Header (72px)
background-color: $white;
z-index: 10000;
}

.fixed-filter-header {
Expand Down

0 comments on commit 5147cea

Please sign in to comment.