When I use a multiple field media-field with the medialibrary field-widget and I try sorting the elements, sorting is not saved.
When I remove the yoast-field from the content-type, sorting is saved correctly. Somehow Yoast seems to interfere with the sorting-save.

Issue fork yoast_seo-3354563

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

quotientix created an issue. See original summary.

danthorne’s picture

Same issue.

interactivex’s picture

We have the same problem with using the pager in the media library pop-up. It seems to have something to do with an error already reported here: https://www.drupal.org/project/yoast_seo/issues/3416502

neliofga’s picture

I can confirm that the Media Library widget no longer saves the item weights when the Real-time SEO field is included.

There's another open issue regarding the same behavior:
https://www.drupal.org/project/yoast_seo/issues/3507356

guillaumeg made their first commit to this issue’s fork.

guillaumeg’s picture

Same issue here, even more annoying when Enable auto refresh of the Real Time SEO widget result is on.

With the help of Claude Opus, I managed to find the root cause and created a Merge Request.
It is ready for review

The details by Claude:

The Yoast preview AJAX (auto-refresh or "SEO preview" button) corrupts the saved order of multi-value media fields (Media Library, file) when the editor reorders items via weights.

Root cause: cacheProcessedEntityForPreview() calls buildEntity(), which runs extractFormValues() on every widget and mutates the cached field_state in $form_state['field_storage'].
The preview response doesn't re-render the widgets, so the browser keeps the original inputs; the next save reuses the same cached form and pairs the mutated field_state with the stale browser weights → corrupted order.

Fix: snapshot field_storage before buildEntity() and restore it after, so building the preview entity has no side effect on the editable form state.

guillaumeg’s picture

Status: Active » Needs review