Skip to content

Commit a2202bd

Browse files
committed
selected menu item in header on mobile
1 parent 60a474c commit a2202bd

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/mainPage/menu.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ const applyMenuCollapsedState = (navMenu: HTMLElement | null): void => {
6161

6262
const isLoggedIn = (): boolean => Boolean(authSession?.info?.isLoggedIn)
6363

64+
const isViewingOwnProfile = (subject: NamedNode): boolean => {
65+
const currentUser = authn.currentUser()
66+
return Boolean(currentUser && subject && currentUser.sameTerm(subject))
67+
}
68+
6469
const ensureMenuSkeleton = () => {
6570
menuCollapsed = loadMenuCollapsedState()
6671
const root = document.querySelector('[role="main"]') || document.body
@@ -264,7 +269,13 @@ const renderMenuItems = async (subject: NamedNode, outliner: OutlineManager, con
264269
const menuItems = await getMenuItems(subject, outliner)
265270

266271
container.replaceChildren(...menuItems.map(createMenuButton))
267-
setActiveMenuItem(container, container.dataset.activePaneName)
272+
// If the user is logged in and viewing their own profile, select "Your profile"
273+
// by default. This also surfaces "Your profile" at the top of the mobile view
274+
// via the menu toggle label, which mirrors the active menu item.
275+
const activePane = isViewingOwnProfile(subject)
276+
? 'profile'
277+
: container.dataset.activePaneName
278+
setActiveMenuItem(container, activePane)
268279
}
269280

270281
export const refreshMenu = (layout: 'mobile' | 'desktop') => {

0 commit comments

Comments
 (0)