Skip to content

feat: enhance drag-and-drop file upload component #410

Open
Madhavi1108 wants to merge 1 commit into
Durgeshwar-AI:mainfrom
Madhavi1108:feature/issue-319-drag-drop
Open

feat: enhance drag-and-drop file upload component #410
Madhavi1108 wants to merge 1 commit into
Durgeshwar-AI:mainfrom
Madhavi1108:feature/issue-319-drag-drop

Conversation

@Madhavi1108

@Madhavi1108 Madhavi1108 commented Jun 22, 2026

Copy link
Copy Markdown

Description

This PR enhances the existing file upload experience by extending the FileUploadArea and useFileUpload implementations with clipboard paste support, configurable validation limits, single/multi-file upload modes, and improved accessibility. These improvements build upon the existing drag-and-drop functionality while preserving backward compatibility with current upload workflows.

The implementation leverages reusable hook configuration, accessible input handling, and configurable upload behavior to provide a more flexible and user-friendly upload experience across the application.

Closes #319

Type of Change

  • New feature
  • Bug fix
  • Refactoring
  • Documentation update

Checklist

  • Code follows project conventions
  • Existing functionality preserved
  • Clipboard paste support implemented
  • Configurable validation limits added
  • Multi-file upload support implemented
  • Accessibility improvements added
  • Ready for testing

What Was Implemented

Clipboard Paste Support

Extended the upload workflow to support direct clipboard pasting.

Updated Hook

  • useFileUpload.js

The hook now listens for the global paste event and automatically detects pasted files such as:

  • Screenshots
  • Copied images
  • Clipboard file attachments

Pasted files are processed through the same validation and upload pipeline as manually selected or dragged files.


Configurable File Validation

Introduced configurable validation rules for uploaded files.

Updated Hook

  • useFileUpload.js

The hook now accepts an options object supporting:

  • maxSize
  • maxFiles

Default values remain:

  • Maximum file size: 10 MB
  • Maximum file count: 1

This allows different tools to customize upload restrictions without duplicating validation logic.


Enhanced Validation Feedback

Improved user feedback for invalid uploads.

Validation now displays clear toast notifications when:

  • Files exceed the configured size limit
  • Uploaded file count exceeds the configured maximum
  • Upload constraints are violated

These messages help users quickly understand and resolve upload issues.


Configurable Upload Modes

Extended the upload component to support both single-file and multi-file workflows.

Updated Component

  • FileUploadArea.jsx

The component now accepts:

  • multiple
  • files

properties to control upload behavior dynamically.

This enables the same component to be reused across tools with differing upload requirements.


Native Multi-File Selection

Updated the underlying file input to support browser-native multi-file selection.

When multiple is enabled:

  • Users may select multiple files simultaneously
  • The selected files are processed using the existing upload pipeline
  • Existing validation logic continues to apply

Single-file behavior remains unchanged by default.


Improved Upload Summary

Enhanced the component's display logic for multi-file scenarios.

Instead of showing only a single filename, the interface now presents summaries such as:

  • 3 files selected

This provides clearer feedback when multiple uploads are involved.


Accessibility Improvements

Improved keyboard accessibility for the upload component.

The hidden file input was updated from:

  • className="hidden"

to:

  • className="sr-only"

allowing keyboard users to navigate to the input while keeping it visually unobtrusive.


Visible Focus Indicators

Added focus styling to improve keyboard navigation.

The upload area now utilizes:

  • focus-within:ring-2
  • focus-within:ring-[var(--color-app-primary)]

to provide a visible focus state whenever the underlying file input receives keyboard focus.

This improves compliance with accessibility best practices while preserving the existing UI design.


Backward Compatibility

Maintained compatibility with existing upload workflows.

Without additional configuration:

  • Single-file uploads continue to function normally
  • The default 10 MB size limit remains unchanged
  • Existing validation and processing logic continue to operate as before

No existing pages require modification to adopt the new behavior.


Shared Upload Pipeline

All supported upload methods now reuse the same processing flow.

Whether files are:

  • Selected through the file picker
  • Dragged into the drop zone
  • Pasted from the clipboard

they pass through identical validation and upload handling, ensuring consistent behavior across all entry points.


Benefits

  • Clipboard paste support for screenshots and images
  • Configurable file size limits
  • Configurable maximum file count
  • Support for single-file uploads
  • Support for multi-file uploads
  • Unified upload processing pipeline
  • Improved validation feedback
  • Enhanced keyboard accessibility
  • Visible focus indicators
  • Better component reusability
  • Preserved backward compatibility
  • Improved overall upload experience

Acceptance Criteria

  • Clipboard paste support implemented
  • Global paste event handled
  • Pasted files processed correctly
  • Configurable maxSize supported
  • Configurable maxFiles supported
  • Default 10 MB size limit preserved
  • Default single-file mode preserved
  • Multi-file upload mode implemented
  • multiple prop supported
  • files prop supported
  • Native multi-file selection enabled
  • Multi-file summary displayed
  • Toast validation messages implemented
  • sr-only accessibility update applied
  • Focus ring styling added
  • Existing upload workflow preserved
  • Existing validation pipeline reused

Technical Notes

  • The useFileUpload hook now accepts configurable validation options while preserving default behavior, allowing upload constraints to be customized per use case without changing shared logic.
  • Clipboard paste support integrates directly into the existing upload pipeline, ensuring pasted files undergo the same validation and processing as manually selected or drag-and-drop uploads.
  • FileUploadArea.jsx now supports configurable single-file and multi-file modes through dedicated component props while enhancing UI feedback for multiple selected files.
  • Accessibility improvements replace fully hidden inputs with screen-reader-only visibility and introduce focus-within styling to improve keyboard navigation and WCAG compliance.
  • The implementation maintains full backward compatibility by preserving default upload limits and existing workflows for all current consumers of the upload component.

@vercel

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown

@Madhavi1108 is attempting to deploy a commit to the Durgeshwar's projects Team on Vercel.

A member of the Team first needs to authorize it.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Drag and Drop File Upload Enhancement

1 participant