Make WordPress Core

Changeset 52384

Timestamp:
12/17/2021 08:15:01 PM (3 years ago)
Author:
antpb
Message:

Media: Fix selections in Media Library Featured Image modal on open.

In [50829] infinite scrolling was removed from the Media Library and modal which introduced unintended behavior for featured images where only the selected image shows when opening the library. This change reverts only the logic that caused this and applies a proper fix when opening the library.

Props benitolopez, hellofromTonya, joedolson, peterwilsoncc, circlecube, danielbachhuber, PieWP, sabernhardt, szaqal21, dariak, sergeybiryukov.
Fixes #53765.

Location:
trunk/src/js/media/controllers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/media/controllers/featured-image.js

    r52288 r52384  
    107107    updateSelection: function() {
    108108        var selection = this.get('selection'),
    109             library = this.get('library'),
    110109            id = wp.media.view.settings.post.featuredImageId,
    111             infiniteScrolling = wp.media.view.settings.infiniteScrolling,
    112110            attachment;
    113111
     
    118116
    119117        selection.reset( attachment ? [ attachment ] : [] );
    120 
    121         if ( ! infiniteScrolling && library.hasMore() ) {
    122             library.more();
    123         }
    124118    }
    125119});
  • trunk/src/js/media/controllers/replace-image.js

    r52288 r52384  
    9191     */
    9292    activate: function() {
    93         this.updateSelection();
     93        this.frame.on( 'content:render:browse', this.updateSelection, this );
     94
    9495        Library.prototype.activate.apply( this, arguments );
     96
     97
     98
     99
     100
     101
     102
     103
     104
    95105    },
    96106
     
    100110    updateSelection: function() {
    101111        var selection = this.get('selection'),
    102             library = this.get('library'),
    103             attachment = this.image.attachment,
    104             infiniteScrolling = wp.media.view.settings.infiniteScrolling;
     112            attachment = this.image.attachment;
    105113
    106114        selection.reset( attachment ? [ attachment ] : [] );
    107 
    108         if ( ! infiniteScrolling && library.getTotalAttachments() === 0 && library.hasMore() ) {
    109             library.more();
    110         }
    111115    }
    112116});
Note: See TracChangeset for help on using the changeset viewer.