Fix contents not loading in filter sidebar (#6240)

This commit is contained in:
WithoutPants 2025-11-06 16:54:53 +11:00 committed by GitHub
parent beee37bc38
commit 2925325e68
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View file

@ -275,6 +275,7 @@ export const SidebarListFilter: React.FC<{
postSelected?: React.ReactNode;
preCandidates?: React.ReactNode;
postCandidates?: React.ReactNode;
onOpen?: () => void;
// used to store open/closed state in SidebarStateContext
sectionID?: string;
}> = ({
@ -292,6 +293,7 @@ export const SidebarListFilter: React.FC<{
postCandidates,
preSelected,
postSelected,
onOpen,
sectionID,
}) => {
// TODO - sort items?
@ -344,6 +346,7 @@ export const SidebarListFilter: React.FC<{
{postSelected ? <div className="extra">{postSelected}</div> : null}
</>
}
onOpen={onOpen}
>
{preCandidates ? <div className="extra">{preCandidates}</div> : null}
<CandidateList

View file

@ -76,10 +76,18 @@ export const SidebarSection: React.FC<
text: React.ReactNode;
className?: string;
outsideCollapse?: React.ReactNode;
onOpen?: () => void;
// used to store open/closed state in SidebarStateContext
sectionID?: string;
}>
> = ({ className = "", text, outsideCollapse, sectionID = "", children }) => {
> = ({
className = "",
text,
outsideCollapse,
onOpen,
sectionID = "",
children,
}) => {
// this is optional
const contextState = React.useContext(SidebarStateContext);
const openState =
@ -93,6 +101,12 @@ export const SidebarSection: React.FC<
}
}
useEffect(() => {
if (openState && onOpen) {
onOpen();
}
}, [openState, onOpen]);
const collapseProps: Partial<CollapseProps> = {
mountOnEnter: true,
unmountOnExit: true,