Skip to content

V15: Dropzone single mode should only allow one file at a time#18847

Merged
iOvergaard merged 1 commit intov15/devfrom
v15/feature/dropzone-single-disable
Mar 27, 2025
Merged

V15: Dropzone single mode should only allow one file at a time#18847
iOvergaard merged 1 commit intov15/devfrom
v15/feature/dropzone-single-disable

Conversation

@iOvergaard
Copy link
Contributor

@iOvergaard iOvergaard commented Mar 27, 2025

Description

It is currently possible to drag another file over a "single-mode" dropzone whilst an upload is pending because the multiple property is only sent to the internal dropzone as ?multiple, meaning that only one file could be selected at a time. However, we would like its behavior to reflect that multiple = false means only one file ever can be uploaded, unless you clear that file.

This disables the internal dropzone if multiple = false and an upload is in progress. You need to clear the files/queue before trying to upload something else, unless multiple=true.

A bonus feature is that we allow to show the "uploader UI" to be shown even though the dropzone is disabled, because otherwise the files would be hidden.

How to test

  1. This is best tested by creating a new media item as the File type and uploading a large enough file, so that you have time to select a second file before the first finishes.

Caveat

One thought is that if a previous upload is in a non-complete state, then we would allow a second file to be uploaded. It could be that you had cancelled a file or its type was ultimately not accepted. I would like an opinion on that.

…is in progress

you need to clear the files/queue before trying to upload something else, unless multiple=true
Copilot AI review requested due to automatic review settings March 27, 2025 13:47
@iOvergaard iOvergaard review requested due to automatic review settings March 27, 2025 13:47
@iOvergaard iOvergaard enabled auto-merge (squash) March 27, 2025 13:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the dropzone behavior in single file mode so that a new file cannot be added while an upload is in progress.

  • Introduces a new private getter (#isDisabled) to centralize the logic determining whether the dropzone should accept uploads.
  • Updates event handlers and UI bindings to use the new disabled state and adjusts styling accordingly.
Comments suppressed due to low confidence (1)

src/Umbraco.Web.UI.Client/src/packages/media/dropzone/components/input-dropzone/input-dropzone.element.ts:83

  • Consider adding unit tests for the new #isDisabled getter to ensure that it correctly identifies when the dropzone should be disabled, especially in cases where an upload is pending with multiple=false.
get #isDisabled(): boolean {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants