Skip to content

Commit

Permalink
Revert "Fix out-of-bounds menus on the admin (#27958)"
Browse files Browse the repository at this point in the history
This reverts commit 2a990ef.
  • Loading branch information
daledupreez committed Jan 12, 2023
1 parent 8bb94bc commit 579d60c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,44 +109,6 @@
}
);
}

if ( jetpackAdminMenu.isAtomic ) {
document.querySelectorAll( 'li.wp-has-submenu.wp-not-current-submenu' ).forEach( function ( el ) {
const submenu = el.querySelector( '.wp-submenu' );
const linkElement = el.querySelector( 'a' );

el.addEventListener( 'mouseover', function() {
submenu.style.display = null;
submenu.style.top = '-1px';
if ( ! isElementInViewport( submenu ) ) {
// Repoisition the submenu to the top of the menu item.
submenu.style.top = ( linkElement.clientHeight - submenu.clientHeight ) + 'px';
}
linkElement.focus();
} );

el.addEventListener( 'mouseleave', function() {
submenu.style.display = 'none';
submenu.style.top = null;
if ( document.activeElement === linkElement ) {
linkElement.blur();
}
} );
} );
}
}

function isElementInViewport( el ) {
var rect = el.getBoundingClientRect();

return (
rect.top >= 0 &&
rect.left >= 0 &&
// Tries to primarily use the window viewport, but if that's not available, uses the documentElement.
// The innerWidth attribute must return the viewport width including the size of a rendered scroll bar (if any), or zero if there is no viewport.
rect.bottom <= ( window.innerHeight || document.documentElement.clientHeight ) &&
rect.right <= ( window.innerWidth || document.documentElement.clientWidth )
);
}

function makeAjaxRequest( method, url, contentType, body = null, callback = null ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
namespace Automattic\Jetpack\Dashboard_Customizations;

use Automattic\Jetpack\Status;
use Automattic\Jetpack\Status\Host;

/**
* Class Base_Admin_Menu
Expand Down Expand Up @@ -278,7 +277,6 @@ public function enqueue_scripts() {
array(
'upsellNudgeJitm' => wp_create_nonce( 'upsell_nudge_jitm' ),
'jitmDismissNonce' => wp_create_nonce( 'jitm_dismiss' ),
'isAtomic' => ( new Host() )->is_woa_site(),
)
);
}
Expand Down

0 comments on commit 579d60c

Please sign in to comment.