[wp-trac] [WordPress Trac] #50105: Remove infinite scrolling behavior from the Media grid

WordPress Trac noreply at wordpress.org
Wed Jun 9 15:38:51 UTC 2021


#50105: Remove infinite scrolling behavior from the Media grid
-------------------------------------+-------------------------------------
 Reporter:  afercia                  |       Owner:  joedolson
     Type:  defect (bug)             |      Status:  reopened
 Priority:  normal                   |   Milestone:  5.8
Component:  Media                    |     Version:
 Severity:  normal                   |  Resolution:
 Keywords:  has-screenshots needs-   |     Focuses:  ui, accessibility,
  dev-note 2nd-opinion needs-        |  javascript
  testing                            |
-------------------------------------+-------------------------------------

Comment (by joedolson):

 This seems to work fine for core.

 For the Unsplash plug-in, it partially works - Unsplash is replacing the
 returned object, however, so the XHR object isn't where we expect it to
 be. We can easily work around that for this one use case, since they
 retain the original response in `_more`:

 {{{

 if ( this.hasOwnProperty( 'getResponseHeader' ) ) {
         collection.totalAttachments = parseInt( this.getResponseHeader( 'X
 -WP-Total' ), 10 );
 } else {
         collection.totalAttachments = parseInt(
 this._more.getResponseHeader( 'X-WP-Total' ), 10 );
 }
 }}}

 Probably not practical for core, though.

 I also tried setting a default value if we couldn't get the total
 attachments.

 {{{

 if ( this.hasOwnProperty( 'getResponseHeader' ) ) {
         collection.totalAttachments = parseInt( this.getResponseHeader( 'X
 -WP-Total' ), 10 );
 } else {
         collection.totalAttachments = 0;
 }
 }}}

 That worked really well for Unsplash, and I can imagine it might be a good
 general solution, though we'd only find that out in real-world testing.

 I did find a bug that occurs when changing tabs - on the initial load of
 the Media Library tab, the load more button appears, but then it's gone if
 you switch away (e.g. to the Upload files tab or to a custom tab, like
 Unsplash.) Exploring this.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50105#comment:106>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list