From 5147ceacf23d2f5bb226c892ef3eb2115a096e4b Mon Sep 17 00:00:00 2001 From: afwilcox Date: Fri, 29 Sep 2023 12:47:20 -0700 Subject: [PATCH] bugfix for sticky header with expanded filters --- .../containers/complaints/complaints.tsx | 16 +++++++++++++++- frontend/src/assets/sass/layout.scss | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/components/containers/complaints/complaints.tsx b/frontend/src/app/components/containers/complaints/complaints.tsx index a065d39ed..15ab950c5 100644 --- a/frontend/src/app/components/containers/complaints/complaints.tsx +++ b/frontend/src/app/components/containers/complaints/complaints.tsx @@ -140,7 +140,21 @@ export const Complaints: FC = ({ defaultComplaintType }) => { 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); + }, })} >