diff --git a/src/js/media/views/attachment.js b/src/js/media/views/attachment.js
index 6f9f7f5..7359570 100644
|
a
|
b
|
Attachment = View.extend(/** @lends wp.media.view.Attachment.prototype */{ |
| 199 | 199 | method = 'toggle'; |
| 200 | 200 | } |
| 201 | 201 | |
| | 202 | // Avoid toggles when the command or control key is pressed with the enter key to prevent deselecting the last selected attachment. |
| | 203 | if ( ( event.metaKey || event.ctrlKey ) && ( 13 === event.keyCode || 10 === event.keyCode ) ) { |
| | 204 | return; |
| | 205 | } |
| | 206 | |
| 202 | 207 | this.toggleSelection({ |
| 203 | 208 | method: method |
| 204 | 209 | }); |
diff --git a/src/js/media/views/modal.js b/src/js/media/views/modal.js
index 8ef4fbb..e3d9ad1 100644
|
a
|
b
|
Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ |
| 180 | 180 | this.escape(); |
| 181 | 181 | }, |
| 182 | 182 | |
| | 183 | /** |
| | 184 | * Handles the selection of attachments when the command or control key is pressed with the enter key. |
| | 185 | * |
| | 186 | * @since 6.7 |
| | 187 | * |
| | 188 | * @param {Object} event The keydown event object. |
| | 189 | */ |
| | 190 | selectHandler: function( event ) { |
| | 191 | var selection = this.controller.state().get( 'selection' ); |
| | 192 | |
| | 193 | if ( ! selection.length > 0 ) { |
| | 194 | return; |
| | 195 | } |
| | 196 | |
| | 197 | if ( 'insert' === this.controller.options.state ) { |
| | 198 | this.controller.trigger( 'insert', selection ); |
| | 199 | } else { |
| | 200 | this.controller.trigger( 'select', selection ); |
| | 201 | event.preventDefault(); |
| | 202 | this.escape(); |
| | 203 | } |
| | 204 | }, |
| | 205 | |
| 183 | 206 | /** |
| 184 | 207 | * @param {Array|Object} content Views to register to '.media-modal-content' |
| 185 | 208 | * @return {wp.media.view.Modal} Returns itself to allow chaining. |
| … |
… |
Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ |
| 214 | 237 | this.escape(); |
| 215 | 238 | event.stopImmediatePropagation(); |
| 216 | 239 | } |
| | 240 | |
| | 241 | // Select the attachment when command or control and enter are pressed. |
| | 242 | if ( ( 13 === event.which || 10 === event.which ) && ( event.metaKey || event.ctrlKey ) ) { |
| | 243 | this.selectHandler( event ); |
| | 244 | event.stopImmediatePropagation(); |
| | 245 | } |
| | 246 | |
| 217 | 247 | } |
| 218 | 248 | }); |
| 219 | 249 | |