-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
fix(sidebar): use placeholders in select menu #7871
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
fix(sidebar): use placeholders in select menu #7871
Conversation
…ebar sometimes current page can be missing from navigation data if the entry is not present in the navigation.json file. In those cases it shows an empty select box on smaller screens. This PR chooses the first item in the navigation tree if the current page is missing from there
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## main #7871 +/- ##
=======================================
Coverage 75.46% 75.46%
=======================================
Files 101 101
Lines 8306 8306
Branches 218 218
=======================================
Hits 6268 6268
Misses 2036 2036
Partials 2 2 ☔ View full report in Codecov by Sentry. |
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.
I feel like this gives the impression that the current page is "Introduction to Node.js". I would rather the placeholder be the title of the current page
@avivkeller That however contradicts with the fact that the page doesn't exist in the select menu 😓 |
…placeholder of the window title in site
@avivkeller I incorporate the changes. The new UX looks like this Screen.Recording.2025-06-18.at.2.18.13.mov |
Each page has a title, can't we use the frontmatter? |
You are right, I am still getting a hang of the new repo. |
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.
Pull Request Overview
This PR addresses empty mobile select boxes when the current page is missing from the sidebar navigation by introducing a placeholder and passing the page title as a default.
- Add an optional
placeholder
prop to theSidebar
component and forward it to the mobile select. - Pull
frontmatter.title
viauseClientContext
inwithSidebar
and supply it as the placeholder.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
packages/ui-components/Containers/Sidebar/index.tsx | Added a placeholder prop to SidebarProps and applied it to the mobile Select . |
apps/site/components/withSidebar.tsx | Imported useClientContext and passed frontmatter?.title into the placeholder . |
Comments suppressed due to low confidence (2)
packages/ui-components/Containers/Sidebar/index.tsx:49
- Add a unit test to verify that when
currentItem
is missing, theplaceholder
prop is displayed and the first navigation item is selected by default.
placeholder={placeholder}
packages/ui-components/Containers/Sidebar/index.tsx:18
- [nitpick] Document the purpose and expected behavior of the
placeholder
prop inSidebarProps
, including when and how it should be used.
placeholder?: string;
Lighthouse Results
|
Description
sometimes current page can be missing from navigation data if the entry is not present in the navigation.json file. In those cases it shows an empty select box on smaller screens. This PR chooses the first item in the navigation tree if the current page is missing from there
Validation
Before
After
Related Issues
Fixes #7646
Check List
pnpm format
to ensure the code follows the style guide.pnpm test
to check if all tests are passing.pnpm build
to check if the website builds without errors.