EntityBrowser widget FileUpload cancel button clashes with Managed File Remove button for image media entities

Created on 6 March 2025, about 1 month ago

Problem/Motivation

For Image type media entities, when trying to upload a media on the fly using the FileUpload Entity Browser widget, we can see 2 buttons - one Cancel and one Remove.

While, the Cancel button works as expected by default, but when pressed after clicking Remove button (added by Drupal image field widget for managed_file type fields) - throws error for missing file.

Error: Call to a member function getFileUri() on null in template_preprocess_file_link() (line 1064 of /var/www/html/docroot/core/modules/file/file.module)

The error is to be expected, since Remove action already deleted the temp uploaded file and then Cancel action is again trying to delete the same file, which does not exist anymore - hence a clash.

Steps to reproduce

Click on Cancel button after Remove button.

Proposed resolution

Since a clash is occurring, the solution I think would be, to not let users use both the buttons. Cancel button works fine, resets the form and also removes the temp file, so the ideal choice would be to disable the functionality of Remove button.

🐛 Bug report
Status

Active

Version

5.0

Component

Code

Created by

🇮🇳India Supreetam09 Kolkata

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024