Skip to content

Vaadin 24.8 DownloadHandler Breaks Cropping #22

Open

Description

@ClancyDamon

Describe the bug

The new DownloadHandler for Image components in Vaadin 24.8.x appears to be breaking the cropping feature. If you change an Image to utilize the new DownloadHandler version of the .setSrc() method as opposed to the now deprecated StreamResource version, the cropping dialog is broken. It displays a broken image instead of the image associated with the component.

I've been trying to debug this, but I haven't yet determined a root cause.

I am testing using a button to invoke the cropping, and I can confirm that the Handler has already been invoked and the image is displayed on my page.

Expected behavior

No response

Minimal reproducible example

No response

Add-on Version

1.1.2

Vaadin Version

24.8.4

Additional information

No response

Activity

  1. javier-godoy commented on Aug 4, 2025

    @javier-godoy
    Member

    Hello. The ImageCrop(Image) constructor currently only supports images with a fixed src, not dynamic resources like DownloadHandler or StreamResource.

    We have created issue #24 to deprecate the current constructor. This issue will remain open to track the future implementation of support for DownloadHandler and StreamResource.

  2. moved this from Inbox (needs triage) to To Do in Flowing Code Addonson Aug 4, 2025
  3. realulim commented on Sep 29, 2026

    @realulim

    I cannot reproduce this issue with version 1.2.2 of ImageCrop. I also have a Vaadin application and recently upgraded it to the new DownloadHandler API and I can see the preview image and the cropping rectangle without any problems. I cannot test the cropping action per se, because for that I need some features I implemented in a fork (https://github.com/iSYS-Software/ImageCrop).

    Anyway, to perhaps help debug this, here is my Vaadin Code to set the source of the preview image:

    Image previewImage = ...
    byte[] content = ...
    String fileName = ...
    previewImage.setSrc(DownloadHandlers.fromInputStream(event ->
                    new DownloadResponse(new ByteArrayInputStream(content), fileName, "image/jpeg", content.length),
                    fileName
                ).inline());
    
    DownloadHandlers.java:
    public static InputStreamDownloadHandler fromInputStream(InputStreamDownloadCallback callback, String fileName) {
        return new InputStreamDownloadHandler(callback) {
            @Override
            public String getUrlPostfix() {
                return fileName;
            }
        };
    }
    
  4. realulim commented on Sep 30, 2026

    @realulim

    Adding to my previous comment: I have now tested the newly released 1.3.0 of ImageCrop and found no issues. I could also test cropping per se now and my test suite is green. So I am now replacing my fork with the upstream again and suspect this issue could be closed, unless the original reporter still sees a problem.

  5. paodb commented on Oct 8, 2026

    @paodb
    Member

    Thanks @realulim for the feedback! However, this issue shouldn't be closed yet: the problem still happens in scenarios where the original Image is not attached or visible (e.g. when it's only used to build the cropper), both in Vaadin 24.8 and 25. We are going to work on it.

    As mentioned before by Javier, the idea is:

    • Add ImageCrop(DownloadHandler) and setImageSrc(DownloadHandler), so the resource is registered to the ImageCrop itself instead of depending on another Image.
    • Add the equivalent StreamResource overloads. Since StreamResource is deprecated for removal since Vaadin 24.8, it will likely be deprecated too, mirroring Image.setSrc(AbstractStreamResource).
  6. paodb commented on Oct 9, 2026

    @paodb
    Member

    A quick update on the plan above: this is being addressed in #37.

    • It will be released in 2.0.0, which requires Vaadin 24.8+ (and supports Vaadin 25), since DownloadHandler is only available from Vaadin 24.8 on. Version 1.x remains available for earlier Vaadin 24 versions.
    • 2.0.0 works only with the new API, so the StreamResource overloads won't be added after all.
    • The deprecated ImageCrop(Image) constructor is removed in 2.0.0. Use ImageCrop(String) or ImageCrop(DownloadHandler) instead.
  7. added a commit that references this issue on Oct 9, 2026
    98d082a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions