Make WordPress Core

Changeset 64299


Ignore:
Timestamp:
10/11/2026 09:00:03 PM (5 weeks ago)
Author:
joedolson
Message:

Media: Improve focus handling on repeated image edits.

Fix a bug where triggering the image edit panel multiple times would successively remove keyboard access to edit controls, beginning with the 2nd instantiation.

Adjust the logic to ensure that tabindex="-1" is only applied to notices, and not to editing controls.

Developed in ​https://github.com/WordPress/wordpress-develop/pull/12921.

Props afercia, rishabhwp, abdullah17, joedolson.
Fixes #65814.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/lib/image-edit.js

    r63600 r64299  
    913913                        var elementToSetFocusTo = $( '.notice[role="alert"]' );
    914914
    915                         if ( ! elementToSetFocusTo.length ) {
    916                                 elementToSetFocusTo = $( '.imgedit-wrap' ).find( ':tabbable:first' );
    917                         }
    918 
    919                         elementToSetFocusTo.attr( 'tabindex', '-1' ).trigger( 'focus' );
     915                        if ( elementToSetFocusTo.length ) {
     916                                elementToSetFocusTo.attr( 'tabindex', '-1' ).trigger( 'focus' );
     917                        } else {
     918                                $( '.imgedit-wrap' ).find( ':tabbable:first' ).trigger( 'focus' );
     919                        }
    920920                }, 100 );
    921921        },
Note: See TracChangeset for help on using the changeset viewer.