Media library widget causes unexpected behaviour on multiple removals

Created on 2 August 2022, about 2 years ago
Updated 14 December 2023, 10 months ago

Problem/Motivation

When using a media library widget for a multi value field, the user can click multiple remove buttons (on media items) while the ajax callback is processing (if the response time is slow enough). This causes unexpected behaviours like not all clicked items being deleted and previously deleted items being restored.

Steps to reproduce

  1. Create a multi-value media reference field with the media library widget
  2. Create a new entity with this field, making sure to add multiple media references
  3. Edit the newly created entity and click multiple remove buttons multiple times without waiting for the ajax callbacks to finish

Notes:

  • The strange behaviour only shows up when doing this multiple times in the same form, so add enough items when trying to reproduce
  • As this relies heavily on the processing time for the ajax request being slow, it might help reproduction to temporarily add a sleep command to the callback

Proposed resolution

Disable other remove buttons / the entire widget while processing removal.

πŸ› Bug report
Status

Needs work

Version

10.1 ✨

Component
MediaΒ  β†’

Last updated about 8 hours ago

Created by

πŸ‡§πŸ‡ͺBelgium L_VanDamme

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024