Skip to content

fix(ui): prevent media drawer thumbnails from eager preloading#16393

Open
mattiaz9 wants to merge 1 commit intopayloadcms:mainfrom
mattiaz9:fix/media-drawer-thumbnail-loading
Open

fix(ui): prevent media drawer thumbnails from eager preloading#16393
mattiaz9 wants to merge 1 commit intopayloadcms:mainfrom
mattiaz9:fix/media-drawer-thumbnail-loading

Conversation

@mattiaz9
Copy link
Copy Markdown

What?

Updates thumbnail rendering to avoid eager image preloading and instead let the browser load thumbnails directly with loading="lazy" / decoding="async". Also adds handling for cached images so thumbnails do not stay in a loading state when drawers are reopened.

Why?

When selecting media with cacheComponents enabled, opening a media drawer with multiple preview thumbnails could trigger refresh/reload behavior and cause unsaved form changes to be lost. Disabling displayPreview avoided the issue, pointing to thumbnail loading as the trigger.

How?

Removes the manual new Image() probe from the thumbnail component, renders the <img> directly, and tracks load/error state through the image element. Cached images are detected via complete / naturalWidth so reopening the drawer does not leave thumbnails showing an indefinite shimmer.

Fixes #16270

@mattiaz9
Copy link
Copy Markdown
Author

I just realized the version in main is v4-beta.
If you plan to merge this please do it in v3, it's almost unusable with cacheComponents enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cache components might cause full page refresh when selecting a media

1 participant