From 88b261ae77e28ba0e04458509b34d21e41685fc1 Mon Sep 17 00:00:00 2001 From: Roland Date: Sat, 26 Sep 2026 12:42:30 -0600 Subject: [PATCH] bookmarks: mark More current when the editor is folded inside it; rem indents in the mobile menu Found on the QA Pi at a width where Bookmarks overflows into More: the More button carried no mark on /more/bookmarks, because the bookmarks link has no `to` for isLinkActive to match. isLinkActive now knows the bookmarks link owns its editor page, and the Bookmarks tab uses the same rule. The mobile menu's directory labels sat a few pixels left of the labels around them: the indent was in em, and a Menu.Label is set smaller than a Menu.Item. Co-Authored-By: Claude Fable 5.1 --- app/src/components/Bookmarks.js | 8 +++++--- app/src/components/Nav.js | 11 ++++++++--- app/src/components/Nav.test.js | 6 ++++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/app/src/components/Bookmarks.js b/app/src/components/Bookmarks.js index 6acd94db..fb6c2b3e 100644 --- a/app/src/components/Bookmarks.js +++ b/app/src/components/Bookmarks.js @@ -26,7 +26,9 @@ function bookmarkItemProps(node) { * * `nested` draws a directory as a flyout (Menu.Sub), which opens beside the menu on hover. * Without it a directory is a labelled, indented run of items instead: the mobile - * hamburger is the one place bookmarks are shown where a flyout cannot be hovered. + * hamburger is the one place bookmarks are shown where a flyout cannot be hovered. The + * indent is in rem: a label is set smaller than an item, so an em indent would put a + * directory's label a few pixels left of the items beside it. */ export function BookmarkMenuItems({nodes, nested = true, depth = 0}) { if (!nodes || nodes.length === 0) { @@ -47,14 +49,14 @@ export function BookmarkMenuItems({nodes, nested = true, depth = 0}) { ; } return - {node.name} + {node.name} ; } return : undefined} > {node.name} diff --git a/app/src/components/Nav.js b/app/src/components/Nav.js index 5455bbc2..188de708 100644 --- a/app/src/components/Nav.js +++ b/app/src/components/Nav.js @@ -166,6 +166,11 @@ NavDropdownTrigger.displayName = 'NavDropdownTrigger'; * the hooks that would answer it cannot be called in a loop. */ export const isLinkActive = (pathname, link) => { + // The Bookmarks menu owns only its editor page: a bookmark pointing at /videos does + // not make the menu own the Videos section. + if (link.bookmarks) { + return pathname === EDIT_BOOKMARKS_PATH || pathname.startsWith(`${EDIT_BOOKMARKS_PATH}/`); + } // An off-site link (Help) is never the current section. if (!link.to || /^[a-z]+:\/\//i.test(link.to)) return false; const to = link.to.length > 1 ? link.to.replace(/\/+$/, '') : link.to; @@ -202,12 +207,12 @@ function DropdownLinks({link}) { /** * The Bookmarks tab: a dropdown that opens on hover as well as on click, holding the - * user's bookmarks and the link to edit them. Marked current on the editor page only; - * a bookmark pointing at /videos does not make this tab own the Videos section. + * user's bookmarks and the link to edit them. Marked current on the editor page only + * (see isLinkActive). */ function BookmarksDropdown({link}) { const {pathname} = useLocation(); - const holdsCurrent = pathname === EDIT_BOOKMARKS_PATH || pathname.startsWith(`${EDIT_BOOKMARKS_PATH}/`); + const holdsCurrent = isLinkActive(pathname, link); return diff --git a/app/src/components/Nav.test.js b/app/src/components/Nav.test.js index eed75499..3e4f88a6 100644 --- a/app/src/components/Nav.test.js +++ b/app/src/components/Nav.test.js @@ -293,6 +293,12 @@ describe('NavBar bookmarks', () => { expect(currentTab()).toEqual([]); }); + it('marks More when the editor page is folded inside it', () => { + useBarWidth(200); + renderWithBookmarks('/more/bookmarks', bookmarks); + expect(screen.getByRole('button', {name: /More/})).toHaveClass('active'); + }); + it('does not own the section a bookmark points at', () => { renderWithBookmarks('/videos/channel', bookmarks); expect(screen.getByRole('button', {name: /Bookmarks/})).not.toHaveClass('active');