Skip to content

Commit 4347dfc

Browse files
authored
Merge pull request #45278 from github/repo-sync
Repo sync
2 parents dfeab5c + 09bc6e5 commit 4347dfc

3 files changed

Lines changed: 47 additions & 2 deletions

File tree

src/frame/components/sidebar/SidebarCollapseContext.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,21 @@ export function SidebarCollapseProvider({
8484
setMobileNavOpen(false)
8585
}, [asPath])
8686

87+
// Growing the viewport to the desktop (xxl) layout takes over from the inline
88+
// mobile nav and hides its toggle, so close the mobile nav when we cross the
89+
// breakpoint — otherwise its open state stays stuck and keeps the content
90+
// column hidden. 1400px mirrors breakpoint-xxl.scss.
91+
useEffect(() => {
92+
if (typeof window === 'undefined' || !window.matchMedia) return
93+
const mql = window.matchMedia('(min-width: 1400px)')
94+
const handle = (e: MediaQueryListEvent | MediaQueryList) => {
95+
if (e.matches) setMobileNavOpen(false)
96+
}
97+
handle(mql) // close immediately if already at/above xxl on mount
98+
mql.addEventListener('change', handle)
99+
return () => mql.removeEventListener('change', handle)
100+
}, [])
101+
87102
const value = useMemo(
88103
() => ({
89104
collapsed,

src/frame/components/sidebar/SidebarNav.module.scss

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,16 @@
1111
}
1212

1313
// When the mobile nav is expanded inline, the rail spans the full width and
14-
// flows in the page (no fixed height / sticky) below the xxl breakpoint.
14+
// flows in the page (no fixed height / sticky) below the xxl breakpoint. At xxl
15+
// the desktop rail takes over, so revert to the fixed rail width even if the
16+
// mobile-open state is momentarily still set (e.g. mid-resize) — otherwise the
17+
// full-width rail covers the article content.
1518
.sidebarFullMobileOpen {
1619
width: 100%;
20+
21+
@include breakpoint-xxl {
22+
width: 326px;
23+
}
1724
}
1825

1926
.sidebarContentFull {
Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
// The tree's typography now comes from @primer/react-brand NavList's own scale
22
// (level-1 section headers at size-200, leaves at size-100). This class is kept
3-
// as the wrapper hook for `data-testid="sidebar"`; intentionally has no rules.
3+
// as the wrapper hook for `data-testid="sidebar"`.
44
.sidebar {
5+
// Brand's NavList draws the active accent bar only on nested leaves — its rule
6+
// explicitly excludes level-1 (`.item--leaf:not(.item--level-1) .link[aria-current]`),
7+
// so a top-level article like "Quickstart" gets only the subtle background pill
8+
// and no green bar. Restore the bar for active top-level leaves to match nested
9+
// items. Brand's classes are hashed, so match on the stable substrings.
10+
:global([class*="NavList__item--leaf"][class*="NavList__item--level-1"])
11+
:global([class*="NavList__link"])[aria-current]:not(
12+
[aria-current="false"]
13+
)::before {
14+
content: "";
15+
position: absolute;
16+
// Level-1 links are shorter (~24px) than nested leaves, so use a small inset
17+
// to keep the bar roughly the height of the background pill rather than the
18+
// larger inset brand applies to taller nested items.
19+
inset-block: var(--base-size-2);
20+
// Level-1 leaves have no inline padding, so pull the bar into the NavList's
21+
// own inline padding gutter to sit left of the label — matching where brand
22+
// places the level-1 indicator on expandable section toggles.
23+
inset-inline-start: calc(-1 * var(--base-size-8));
24+
width: var(--base-size-4);
25+
border-radius: var(--base-size-2);
26+
background-color: var(--brand-NavList-activeIndicator-color);
27+
}
528
}

0 commit comments

Comments
 (0)