Skip to content

Commit

Permalink
Media: Fix focus loss when closing Image Rotation menu.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
joedolson committed Sep 14, 2023
1 parent 73d8392 commit 227fdb8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/js/_enqueues/lib/image-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
Expand Down

0 comments on commit 227fdb8

Please sign in to comment.