From 25ef84077900237c999c8e10f465e6b06377dc00 Mon Sep 17 00:00:00 2001 From: Khokan Sardar Date: Wed, 22 Jul 2026 15:15:03 +0530 Subject: [PATCH 1/2] Menus: Prevent lost first click on the sticky footer buttons. The focus handler that keeps menu-item fields from being hidden behind the sticky footer also matched the footer's own Save Menu and Delete Menu controls. Focusing one of those on mousedown scrolled the page, moving the control out from under the pointer, so the mouseup and click landed on an ancestor element and the delegated click handler never ran. The first click was silently lost; only a second click worked. Skip the scroll-into-view adjustment when the focused control is inside the #nav-menu-footer, which is always visible in the viewport while sticky and so never needs to be scrolled into view. Fixes #65684. --- src/js/_enqueues/lib/nav-menu.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/js/_enqueues/lib/nav-menu.js b/src/js/_enqueues/lib/nav-menu.js index 79917c8447f1a..d0eefe0702c32 100644 --- a/src/js/_enqueues/lib/nav-menu.js +++ b/src/js/_enqueues/lib/nav-menu.js @@ -1869,6 +1869,12 @@ // Prevent focused element from being hidden by the sticky footer. $( '.menu-edit a, .menu-edit button, .menu-edit input, .menu-edit textarea, .menu-edit select' ).on('focus', function() { + // The sticky footer's own controls are always in view, so scrolling + // to reveal them would shift the footer out from under the pointer + // mid-click and drop the Save or Delete activation. See #65684. + if ( $( this ).closest( '#nav-menu-footer' ).length ) { + return; + } if ( window.innerWidth >= 783 ) { var navMenuHeight = $( '#nav-menu-footer' ).height() + 20; var bottomOffset = $(this).offset().top - ( $(window).scrollTop() + $(window).height() - $(this).height() ); From 732d63b4f640bf6551b8bfc9cb76303133c0716d Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Sat, 7 Nov 2026 18:13:20 -0600 Subject: [PATCH 2/2] Update e2e tests to remove 65684 workarounds. --- tests/e2e/specs/classic-menus.test.js | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/tests/e2e/specs/classic-menus.test.js b/tests/e2e/specs/classic-menus.test.js index c3a82f5451aaf..4bb789c860217 100644 --- a/tests/e2e/specs/classic-menus.test.js +++ b/tests/e2e/specs/classic-menus.test.js @@ -54,19 +54,8 @@ test.describe( 'Classic Menus', () => { ).toBeVisible(); // Assign the menu to the theme's primary location and save. - const primaryMenu = page.getByRole( 'checkbox', { - name: 'Primary menu', - } ); - // Use the keyboard to avoid the focus-induced scroll described in #65684. - await primaryMenu.focus(); - await page.keyboard.press( 'Space' ); - await expect( primaryMenu ).toBeChecked(); - - // Activate via keyboard: the sticky footer bar can shift on focus - // and swallow the first pointer click at certain window heights. - // See https://core.trac.wordpress.org/ticket/65684. - await page.locator( '#save_menu_footer' ).focus(); - await page.keyboard.press( 'Enter' ); + await page.getByRole( 'checkbox', { name: 'Primary menu' } ).check(); + await page.locator( '#save_menu_footer' ).click(); // The location assignment persists. await expect @@ -102,12 +91,7 @@ test.describe( 'Classic Menus', () => { // Deleting asks for confirmation. page.on( 'dialog', ( dialog ) => dialog.accept() ); - - // Activate via keyboard: the sticky footer bar can shift on focus - // and swallow the first pointer click at certain window heights. - // See https://core.trac.wordpress.org/ticket/65684. - await page.getByRole( 'link', { name: 'Delete Menu' } ).focus(); - await page.keyboard.press( 'Enter' ); + await page.getByRole( 'link', { name: 'Delete Menu' } ).click(); // With the only menu gone, the screen returns to the create form. await expect(