Index: wp-content/themes/twentytwentyone/assets/js/primary-navigation.js
===================================================================
--- wp-content/themes/twentytwentyone/assets/js/primary-navigation.js	(revision 58805)
+++ wp-content/themes/twentytwentyone/assets/js/primary-navigation.js	(working copy)
@@ -111,12 +111,25 @@
 			return;
 		}
 
-		if ( mobileButton ) {
-			mobileButton.onclick = function() {
-				wrapper.classList.toggle( id + '-navigation-open' );
-				wrapper.classList.toggle( 'lock-scrolling' );
-				twentytwentyoneToggleAriaExpanded( mobileButton );
-				mobileButton.focus();
+		if (mobileButton) {
+			let scrollPosition = 0; // To store the current scroll position
+		
+			mobileButton.onclick = function () {
+				const isMenuOpen = wrapper.classList.contains(id + '-navigation-open');
+		
+				if (!isMenuOpen) {
+					// Save the scroll position when opening the menu
+					scrollPosition = window.scrollY;
+				}
+		
+				wrapper.classList.toggle(id + '-navigation-open');
+				wrapper.classList.toggle('lock-scrolling');
+				twentytwentyoneToggleAriaExpanded(mobileButton);
+		
+				if (isMenuOpen) {
+					// Restore scroll position when closing the menu
+					window.scrollTo(0, scrollPosition);
+				}
 			};
 		}
 
