[wp-trac] [WordPress Trac] #50105: Remove infinite scrolling behavior from the Media grid
WordPress Trac
noreply at wordpress.org
Wed May 6 15:32:35 UTC 2020
#50105: Remove infinite scrolling behavior from the Media grid
-------------------------------------+-------------------------------------
Reporter: afercia | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 5.5
Component: Media | Version:
Severity: normal | Resolution:
Keywords: has-patch has- | Focuses: ui, accessibility,
screenshots | javascript
-------------------------------------+-------------------------------------
Changes (by afercia):
* keywords: => has-patch has-screenshots
Comment:
[attachment:"50105.diff"] is a proof of concept meant for initial testing.
Still to do:
- update the number of total attachments when adding / removing
attachments
- more testing
It would be great to run extended testing on different installations, with
a varying mount of attachments stored in the media library. I'd suggest to
focus on:
- general behavior
- whether the default "per page" of 40 attachments should be increased
- filtering by type and date, keeping in mind there are existing bugs when
filtering see for example #50025.
**Suggestions for testing:**
- styling of the button / spinner / etc. is temporary, please ignore it
for now
- throttle the network via your browser's dev tools: this helps in
observing the UI behavior e.g. the spinner visibility
- test without and with media trash enabled (by setting `define(
'MEDIA_TRASH', true );` in your `wp-config.php` file)
- test the filter `add_filter( 'media_library_infinite_scrolling',
'__return_true' );` to restore the infinite scrolling behavior
- test the Media Library
- test the Media modal with Classic Editor (Add Media, featured image)
- test the Media modal with Gutenberg (image, gallery, featured image...)
- optionally: test the Media modal with plugins that implement custom
frames to upload / select attachments
- inspect the `queries` array of cached collections
**Accessibility:**
For now, clicking the "load more" sets focus on the first added
attachment. I think it would be best to explore other options, as moving
focus unexpectedly should preferably be avoided.
**Questions:**
1
The patch changes the data returned by the WP_Query used to retrieve
attachments. Previously, the response only held the array of attachments.
Now, it holds 2 items:
- the array of attachments
- the number of total attachments, that is: `found_posts`
Later, the response is parsed so that it passes the attachments array to
the views and sets a new property for the number of total attachments.
Basically, the response and the cached `queries` use a different format.
An interesting question in this regard is: should the old format be kept
when the `media_library_infinite_scrolling` filter restore infinite
scrolling? The media grid works regardless but I guess this should be
explored for potential backwards compatibility issues?
2
One more interesting question for anyone familiar with the history of the
media views is what are the various "compat" methods meant for? This part
is a bit obscure to me. See things like:
- `Attachment.saveCompat`
- the AJAX call `save-attachment-compat` and related
`wp_ajax_save_attachment_compat`
- the `attachment_fields_to_edit` things (I ''think'' this was used for
the old upload method?)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/50105#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list