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');