Skip to content

Commit

Permalink
Expand click-outside exceptions
Browse files Browse the repository at this point in the history
Chase Gutenberg's ever-changing elements
  • Loading branch information
johngodley committed Sep 7, 2021
1 parent 3c16664 commit 592f836
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/components/block-editor-container/click-outside.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,27 @@ const ClickOutsideWrapper = withFocusOutside(
this.props.onFocus();
}

// Clicks in the media modal or popup components are considered in the editor
isInspectorElement( element ) {
if ( element.closest( '.components-color-picker' ) ) {
return true;
}

if ( element.closest( '.block-editor-block-inspector' ) ) {
return true;
}

if ( element.classList.contains( 'media-modal' ) ) {
return true;
}

return false;
}

handleFocusOutside( ev ) {
const target = ev.relatedTarget || ev.target;

// Ignore clicks in the media modal - consider it inside the editor
if ( target && target.classList.contains( 'media-modal' ) ) {
if ( target && this.isInspectorElement( target ) ) {
return;
}

Expand Down

0 comments on commit 592f836

Please sign in to comment.