From ea486168339b8288dc0cee062caa25a1cc8bdf3d Mon Sep 17 00:00:00 2001 From: Andrew Jiang Date: Thu, 9 May 2024 19:07:58 -0400 Subject: [PATCH] fix: support nested FlattenApiSection (#840) --- .../ui/app/src/sidebar/SidebarApiSection.tsx | 75 +++++++++++-------- 1 file changed, 44 insertions(+), 31 deletions(-) diff --git a/packages/ui/app/src/sidebar/SidebarApiSection.tsx b/packages/ui/app/src/sidebar/SidebarApiSection.tsx index 67ce20a311..12844cf55e 100644 --- a/packages/ui/app/src/sidebar/SidebarApiSection.tsx +++ b/packages/ui/app/src/sidebar/SidebarApiSection.tsx @@ -28,39 +28,21 @@ export const SidebarApiSection: React.FC = ({ }) => { const { selectedSlug } = useCollapseSidebar(); + if (apiSection.isSidebarFlattened) { + return ( +
  • + +
  • + ); + } + return depth === 0 ? (
  • - {apiSection.isSidebarFlattened ? ( -
      - {apiSection.items.map((item) => - visitDiscriminatedUnion(item, "type")._visit({ - apiSection: (item) => ( - - ), - page: (item) => ( - - ), - _other: () => ( - - ), - }), - )} -
    - ) : apiSection.summaryPage != null ? ( + {apiSection.summaryPage != null ? ( ); }; + +function FlattenedApiSection({ apiSection, registerScrolledToPathListener, depth }: SidebarApiSectionProps) { + return ( +
      + {apiSection.items.map((item) => + visitDiscriminatedUnion(item, "type")._visit({ + apiSection: (item) => ( + + ), + page: (item) => ( + + ), + _other: () => ( + + ), + }), + )} +
    + ); +}