File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,6 +51,8 @@ if (!isEmbedded) {
5151 // We observe on mousedown because we only care about user resize.
5252 sidebar . addEventListener ( 'mousedown' , ( ) => resizeObserver . observe ( sidebar ) )
5353 sidebar . addEventListener ( 'mouseup' , ( ) => resizeObserver . unobserve ( sidebar ) )
54+
55+ window . addEventListener ( 'hashchange' , maybeCloseSidebarOnNavigate )
5456}
5557
5658function setDefaultSidebarState ( ) {
@@ -114,3 +116,13 @@ function transitionSidebar (open) {
114116export function openSidebar ( ) {
115117 return transitionSidebar ( true )
116118}
119+
120+ /**
121+ * Closes the sidebar on small screens when navigating between sections
122+ * on the page, for consistency with full page transitions
123+ */
124+ function maybeCloseSidebarOnNavigate ( ) {
125+ if ( smallScreenQuery . matches && isSidebarOpen ( ) ) {
126+ transitionSidebar ( false )
127+ }
128+ }
You can’t perform that action at this time.
0 commit comments