Skip to content

Shift on max files feature starts replacing images too early #6

@dhruvsakariya

Description

@dhruvsakariya
shadcn-dropzone.mp4

When adding multiple images with the shiftOnMaxFiles flag enabled, it should remove the oldest image once the limit is reached. For example, if the limit is 10, uploading the 11th image should remove the first image while keeping the latest ones.

However, this feature is not working correctly. Instead of waiting until the limit is reached, image replacement starts prematurely around 5 images instead of 10 causing unexpected behavior.

Steps to Reproduce:

  1. Open the provided sandbox: Codesandbox Link
  2. Drop files up to half of the defined limit.
  3. Attempt to add more files.
  4. Observe that new files replace previously added ones instead of being appended.

Suspected Cause:
The issue appears to be in the onDropAccepted function, where the validation logic isn't correctly preventing additional file additions.

Proposed Fix:
I've identified and implemented a fix in my local repository, where the max file limit is properly enforced. I would like to submit a PR to contribute the fix to the main repository.

Let me know if I can proceed with opening a PR or if any clarification is needed.

Best
Dhruv

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions