Customize: Prevent collapsing expanded panel/section/control when Esc is pressed on a block editor instance.

This ensures that the current panel is not collapsed when hitting `Esc` with the focus on the widget block editor.

Follow-up to [37347], [39120].

Props gwwar, dlh.
Fixes #54030.

git-svn-id: https://develop.svn.wordpress.org/trunk@51682 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2021-08-28 01:24:13 +00:00
parent 52fe9ffbd5
commit 780be4296a

View File

@ -8461,6 +8461,13 @@
return;
}
// Abort if we're inside of a block editor instance.
if ( event.target.closest( '.block-editor-writing-flow' ) !== null
|| event.target.closest( '.block-editor-block-list__block-popover' ) !== null
) {
return;
}
// Check for expanded expandable controls (e.g. widgets and nav menus items), sections, and panels.
api.control.each( function( control ) {
if ( control.expanded && control.expanded() && _.isFunction( control.collapse ) ) {