[fix] Allow empty section pages in top navigation similar to how we do it for sidebar nav #12247
Conversation
🎉 Snyk checks have passed. No issues have been found so far.✅ security/snyk check is complete. No issues have been found. (View Details) ✅ license/snyk check is complete. No issues have been found. (View Details) |
frontend/lib/src/components/widgets/DataFrame/columns/SelectboxColumn.ts
Outdated
Show resolved
Hide resolved
f52e3ab to
dfa5aa7
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR fixes issue #12243 where pages with empty section headers ("") were incorrectly grouped in an unlabeled dropdown in the top navigation. The fix ensures that empty section pages appear as individual navigation items when mixed with sectioned pages, matching the behavior of sidebar navigation.
- Added shared navigation utilities to ensure consistent handling of empty sections between TopNav and SidebarNav components
- Refactored TopNav and SidebarNav to use the same shared processing logic
- Updated test IDs to properly distinguish between different navigation contexts
Reviewed Changes
Copilot reviewed 10 out of 54 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
frontend/app/src/components/Navigation/utils.ts |
Added shared navigation processing utilities for consistent handling of empty sections |
frontend/app/src/components/Navigation/utils.test.ts |
Added comprehensive unit tests for the new navigation utilities |
frontend/app/src/components/Navigation/TopNav.tsx |
Refactored to use shared utilities and fix empty section handling |
frontend/app/src/components/Navigation/TopNavSection.tsx |
Updated test IDs and added dropdown context parameter |
frontend/app/src/components/Navigation/SidebarNavLink.tsx |
Enhanced test ID logic to distinguish dropdown links from regular nav links |
frontend/app/src/components/Navigation/SidebarNav.tsx |
Refactored to use shared utilities and removed navSections prop |
frontend/app/src/components/Navigation/SidebarNav.test.tsx |
Updated tests to work with refactored component interface |
frontend/app/src/components/Sidebar/Sidebar.tsx |
Removed obsolete navSections prop from SidebarNav |
e2e_playwright/multipage_apps_v2/mpa_v2_top_nav.py |
Added test case for mixed empty and named sections |
e2e_playwright/multipage_apps_v2/mpa_v2_top_nav_test.py |
Added comprehensive E2E tests for mixed section navigation |
2d85ef4 to
3bf71fc
Compare
There was a problem hiding this comment.
at the root level.
and always on the top of the nav menu, right?
There was a problem hiding this comment.
For now, yes. @sfc-gh-dmatthews had some thoughts about expanding on this further and allowing multiple different empty keys and allowing you to intermix so lets say the first section is "" and then next is "Section A" and then after section a is "_" or " " or "undefined" and then "Section B" allowing you to interweave the sections and pages. I think the sidebar design might need some work to make this look good, so I held off adding that in this PR.
lukasmasuch
left a comment
There was a problem hiding this comment.
LGTM 👍 One clarification question
This file provides essential information for Claude Code instances working with the Streamlit codebase, including common commands, architecture overview, and development patterns. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Pages with empty section headers ("") now appear as individual items
in the top navigation bar when mixed with sectioned pages, matching
the behavior of sidebar navigation.
Changes:
- Add shared navigation utilities to process nav structure consistently
- Refactor TopNav to use shared utilities, fixing the unlabeled dropdown bug
- Refactor SidebarNav to use shared utilities for consistency
- Update test IDs to distinguish nav links from dropdown sections
- Add E2E test for mixed empty/named sections scenario
- Add comprehensive unit tests for navigation utilities
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
…larify purpose and scope
9fe1142 to
e9379cc
Compare
Summary
This PR fixes issue #12243 where pages with empty section headers ("") were incorrectly grouped in an unlabeled dropdown in the top navigation. They now appear as individual navigation items when mixed with sectioned pages, matching the behavior of sidebar navigation.
Changes
processNavigationStructure) to ensure consistent handling of empty sections between TopNav and SidebarNav componentsThere's a couple suggestions @sfc-gh-dmatthews made that I think would be great here, but going to do in a follow up PR for easier review.
Another followup task could be to change what's getting screenshotted in the test app, or change the test app to use query params instead of checkboxes to avoid snap diffs on changing the options in the test app.
Testing
Added unit tests for utils and changed functionality. Added e2e tests. Manually verified.
Before/After
Before: Pages with empty section headers appeared in an unlabeled dropdown
After: Pages with empty section headers appear as individual navigation items
Example Usage
Fixes #12243
🤖 Generated with Claude Code