Media: Fix focus loss when closing Image Rotation menu.

Only shift focus into menu when opening the menu. Check `aria-expanded` value of toggle before moving focus.

Props joedolson.
Fixes #59353.

git-svn-id: https://develop.svn.wordpress.org/trunk@56591 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Joe Dolson 2023-09-14 22:33:50 +00:00
parent 73d839264f
commit 227fdb8b74

View File

@ -236,8 +236,10 @@
// Open menu and set z-index to appear above image crop area if it is enabled.
$target
.toggleClass( 'imgedit-popup-menu-open' ).slideToggle( 'fast' ).css( { 'z-index' : 200000 } );
// Move focus to first item in menu.
$target.find( 'button' ).first().trigger( 'focus' );
// Move focus to first item in menu when opening menu.
if ( 'true' === $el.attr( 'aria-expanded' ) ) {
$target.find( 'button' ).first().trigger( 'focus' );
}
return false;
},