wordpress-develop icon indicating copy to clipboard operation
wordpress-develop copied to clipboard

refact: update the media item modal loader to load all images until current

Open rutviksavsani opened this issue 1 week ago • 2 comments

Summary

Fixes broken media library navigation when accessing items beyond the initial page load via direct URL after a page refresh.

Trac ticket: https://core.trac.wordpress.org/ticket/54091

Solution

Implemented a two-phase loading strategy:

  1. Immediate fetch - Opens the item instantly as it currently does.
  2. Background context loading - Recursively loads library batches until the item is found in the collection, then enables navigation.

Changes Made

src/js/media/routers/manage.js

  • Added recursive batch loading to load all the images in library till the image found in the backend.
  • Updates edit frame model once item is found in collection to enable navigation.

src/js/media/views/frame/edit-attachments.js

  • Added -1 index check to hasNext() and hasPrevious()

Screen Recording

https://github.com/user-attachments/assets/a1a9dfae-b62f-46af-9e28-866bae98f40f


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

rutviksavsani avatar Jan 14 '26 06:01 rutviksavsani