Make WordPress Core

Ticket #60369: 60369-2.patch

File 60369-2.patch, 1.8 KB (added by antpb, 2 years ago)

fixes Classic Editor media select views

  • src/js/media/views/attachment.js

     
    199199                        method = 'toggle';
    200200                }
    201201
     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
    202207                this.toggleSelection({
    203208                        method: method
    204209                });
  • src/js/media/views/modal.js

     
    181181        },
    182182
    183183        /**
     184         * Handles the selection of attachments when the command or control key is pressed with the enter key.
     185         *
     186         * @since 6.6
     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
     206        /**
    184207         * @param {Array|Object} content Views to register to '.media-modal-content'
    185208         * @return {wp.media.view.Modal} Returns itself to allow chaining.
    186209         */
     
    214237                        this.escape();
    215238                        event.stopImmediatePropagation();
    216239                }
     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
    217247        }
    218248});
    219249