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

WordPress Trac noreply at wordpress.org
Wed May 19 16:45:08 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               |  javascript
-------------------------------------+-------------------------------------

Comment (by spacedmonkey):

 There maybe other plugins out there that are using these reusing
 underscore views but do not override the admin ajax calls. In the Unsplash
 plugin for example, we have a custom REST API endpoint, the replicates the
 format of the admin ajax call.

 Currently the view does this.

 {{{#!php
         parse: function( response, xhr ) {
                 if ( ! _.isArray( response.attachments ) ) {
                         response = [ response.attachments ];
                 }

                 this.totalAttachments = parseInt(
 response.totalAttachments, 10 );

 }}}

 However, as documented above, the properties attachments and
 totalAttachments may not exist. The code should check first to see if
 these properties exist, if, they do not fall back to the previous
 behavior.  If totalAttachments does not exist, infinite scroll should also
 be re-enabled.

 Something like this might work.

 {{{#!php
         parse: function( response, xhr ) {
                 if ( response.hasOwnProperty('attachments') && !
 _.isArray( response.attachments ) ) {
                         response = [ response.attachments ];
                 }

                 if ( response.hasOwnProperty('totalAttachments') ) {
                     this.totalAttachments = parseInt(
 response.totalAttachments, 10 );
                 }

 }}}

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


More information about the wp-trac mailing list