Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Write editor: Fix media modal closing when mouse drag moves outside the modal during text selection.
13 changes: 13 additions & 0 deletions projects/packages/jetpack-mu-wpcom/src/features/write/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -2713,6 +2713,19 @@ const { state } = store( 'wpcom-write', {
}
},

// Close whichever media modal is open, but only when the pointerdown
// lands directly on the overlay backdrop — not when it starts inside
// the modal (e.g. while selecting text in an input) and drags out.
handleOverlayPointerDown( event ) {
if ( event.button !== 0 || event.target !== event.currentTarget ) return;
const { actions: a } = store( 'wpcom-write' );
if ( state.showImageModal ) {
a.closeImageModal();
} else if ( state.showVideoModal ) {
a.closeVideoModal();
}
},

stopPropagation( event ) {
event.stopPropagation();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ class="bw-content<?php echo $edit_content ? '' : ' bw-is-empty'; ?>"
</main>

<!-- Image modal -->
<div class="bw-image-overlay" hidden data-wp-bind--hidden="!state.showImageModal" data-wp-on--click="actions.closeImageModal" data-wp-on--keydown="actions.handleImageModalKeyDown" data-wp-on--dragover="actions.handleOverlayDragOver" data-wp-on--drop="actions.handleOverlayDrop">
<div class="bw-image-overlay" hidden data-wp-bind--hidden="!state.showImageModal" data-wp-on--pointerdown="actions.handleOverlayPointerDown" data-wp-on--keydown="actions.handleImageModalKeyDown" data-wp-on--dragover="actions.handleOverlayDragOver" data-wp-on--drop="actions.handleOverlayDrop">
<div class="bw-image-modal" role="dialog" aria-modal="true" aria-label="<?php echo esc_attr__( 'Add an image', 'jetpack-mu-wpcom' ); ?>" data-wp-on--click="actions.stopPropagation" data-wp-on--dragover="actions.handleOverlayDragOver" data-wp-on--drop="actions.handleOverlayDrop">
<h3><?php echo esc_html__( 'Add an image', 'jetpack-mu-wpcom' ); ?></h3>
<label class="bw-upload-zone" id="bw-upload-zone" data-wp-on--dragover="actions.handleDragOver" data-wp-on--dragleave="actions.handleDragLeave" data-wp-on--drop="actions.handleDrop">
Expand Down Expand Up @@ -607,7 +607,7 @@ class="bw-image-url-input"
</div>

<!-- Video modal -->
<div class="bw-image-overlay" hidden data-wp-bind--hidden="!state.showVideoModal" data-wp-on--click="actions.closeVideoModal" data-wp-on--keydown="actions.handleVideoModalKeyDown">
<div class="bw-image-overlay" hidden data-wp-bind--hidden="!state.showVideoModal" data-wp-on--pointerdown="actions.handleOverlayPointerDown" data-wp-on--keydown="actions.handleVideoModalKeyDown">
<div class="bw-image-modal" role="dialog" aria-modal="true" aria-label="<?php echo esc_attr__( 'Embed a video', 'jetpack-mu-wpcom' ); ?>" data-wp-on--click="actions.stopPropagation">
<h3><?php echo esc_html__( 'Embed a video', 'jetpack-mu-wpcom' ); ?></h3>
<input
Expand Down
Loading