-
Notifications
You must be signed in to change notification settings - Fork 10
feat: include hidden items in nav tree with hidden flag #1028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -138,13 +138,19 @@ export const visitSection = ( | |
| .flat() | ||
| .filter((child): child is NavItem => child !== undefined); | ||
|
|
||
| // Only include section in nav if it has children and is not hidden | ||
| if (children.length === 0 || sectionItem.hidden) { | ||
| // Skip section from nav if it has no children | ||
| if (children.length === 0) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Now that hidden pages/API items are emitted with Useful? React with 👍 / 👎. |
||
| return { indexEntries, navItem: undefined }; | ||
| } | ||
|
|
||
| // Update section nav item with children | ||
| // Update section nav item with children. | ||
| // Mark hidden if explicitly hidden OR if every child is hidden | ||
| // (prevents empty section headers when consumers filter hidden items). | ||
| sectionNavItem.children = children; | ||
| const allChildrenHidden = children.every((child) => child.hidden === true); | ||
| if (sectionItem.hidden || allChildrenHidden) { | ||
| sectionNavItem.hidden = true; | ||
| } | ||
|
|
||
| return { indexEntries, navItem: sectionNavItem }; | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
descriptionis always emitted as a property even when it isundefined, which meansnavItemwill containdescription: undefined. This can break strict deep-equality expectations and produces noisier serialized output. Consider only includingdescriptionwhen it’s defined (e.g., via conditional object spread), and update the related test expectations accordingly.