Here are the steps:

  1. In a multi-value image field of a content type, add 3 images that are below the "Maximum upload size". Let say that Maximum is 3MB and the uploaded files are 2.5MB
  2. Save the node
  3. In the image field settings, change the "Maximum upload size" to 2MB
  4. Edit the node and try to remove images

It is not possible to remove the images (by clicking the "remove" button) because, when doing this, the field are highlighted in red due to a validation error regarding their size

Comments

DuneBL created an issue. See original summary.

samuel.mortenson’s picture

Status: Active » Needs review
StatusFileSize
new1.08 KB

I copied FileWidget's handling of this exact problem - do you mind trying it out for me @DuneBL?

  • samuel.mortenson committed 8d477b1 on 8.x-1.x
    Issue #2731957 by samuel.mortenson, DuneBL: untimely validation for "...
samuel.mortenson’s picture

Status: Needs review » Fixed
dunebl’s picture

Sorry for my late answer.
I have tested with a simple value field:
1-upload a 1.8 MB file
2-Change field property: Max=1Mb
3-Edit the node to try to remove the file

Result=the "description" subfield of the file field is red (without message)
widget=Browser for file (modal)

If I change the file field definition by removing the "Activate description field" and after that if I try to remove the file, I don't have any message, and no red square, but nothing happens: the file is not removed

As a side node, firstly I didn't apply the patch because I saw it was committed; but in fact, it was not the case.
I use "composer require" to install all my module.
But after a "composer update" file_browser didn't get updated and the patch was not included.
Here is my extract of composer.lock

           "name": "drupal/file_browser",
            "version": "dev-1.0.x",
            "source": {
                "type": "git",
                "url": "https://git.drupal.org/project/file_browser",
                "reference": "6d1c03f30871eb4ac2585ed0dc8c9f324d50c96d"
            },
samuel.mortenson’s picture

Status: Fixed » Needs review
StatusFileSize
new1.32 KB

@DuneBL You're right, sorry for committing early. I was trying to get some other changes in and based on my testing (which missed the bug), this was working. Could you try this new patch and let me know if it works out for you?

samuel.mortenson’s picture

Status: Needs review » Needs work
StatusFileSize
new1.22 KB

The last patch will break translation, this one should work with any button #value.

samuel.mortenson’s picture

Status: Needs work » Needs review
dunebl’s picture

In confirm that #7 is doing the job!!

Thanks for this

  • samuel.mortenson committed 5f33316 on 8.x-1.x
    Follow up on Issue #2731957, fix logic and keep support for translations...
samuel.mortenson’s picture

Status: Needs review » Fixed

Nice! Thanks for the review.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.