diff --git a/src/js/_enqueues/lib/nav-menu.js b/src/js/_enqueues/lib/nav-menu.js index 5e94a2b34f3c9..5f9e0dfc5f8b1 100644 --- a/src/js/_enqueues/lib/nav-menu.js +++ b/src/js/_enqueues/lib/nav-menu.js @@ -1893,6 +1893,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() ); 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(