Skip to content

feat: Add clipboard paste and drag-and-drop file support#5820

Open
garypretty wants to merge 9 commits into
microsoft:mainfrom
garypretty:feature/paste-and-dragdrop
Open

feat: Add clipboard paste and drag-and-drop file support#5820
garypretty wants to merge 9 commits into
microsoft:mainfrom
garypretty:feature/paste-and-dragdrop

Conversation

@garypretty
Copy link
Copy Markdown

@garypretty garypretty commented May 11, 2026

Fixes #

Changelog Entry

  • Added clipboard paste support for file attachments in both basic and fluent themes.
  • Added drag-and-drop file support to basic theme via new DropZone component.

Description

Users currently have no way to paste files from the clipboard or drag-and-drop files onto the send box. The fluent theme has a DropZone for drag-and-drop but neither theme supports paste. This PR adds both capabilities consistently across both themes, using the existing attachment pipeline (useSendBoxAttachments, useMakeThumbnail).

Design

  • Paste: An onPaste handler on the send box container div extracts files from ClipboardEvent.clipboardData.files and feeds them into handleAddFiles, which generates thumbnails and appends to the existing attachment list.
  • Drag-and-drop (basic theme): A new DropZone component adapted from the fluent theme's implementation, using emotion CSS-in-JS. Shows an overlay when files are dragged over the page.
  • Both features respect disableFileUpload and uiState === 'disabled'.
  • sendAttachmentOn: 'attach' is honored (auto-submit after files added).

Specific Changes

  • packages/component/src/SendBox/BasicSendBox.tsx — added onPaste handler, DropZone, handleAddFiles helper, disabled state gating

  • packages/component/src/SendBox/DropZone.tsx — new drop zone overlay component for basic theme

  • packages/component/src/testIds.ts — added sendBoxDropZone test ID

  • packages/fluent-theme/src/components/sendBox/SendBox.tsx — added onPaste handler using existing handleAddFiles

  • __tests__/html2/basic/pasteFile.html — E2E test for paste (single and multiple file accumulation)

  • __tests__/html2/basic/dragAndDrop.upload.html — E2E test for drag-and-drop in basic theme

  • I have added tests and executed them locally

  • I have updated CHANGELOG.md

  • I have updated documentation

Review Checklist

This section is for contributors to review your work.

  • Accessibility reviewed (tab order, content readability, alt text, color contrast)
  • Browser and platform compatibilities reviewed
  • CSS styles reviewed (minimal rules, no z-index)
  • Documents reviewed (docs, samples, live demo)
  • Internationalization reviewed (strings, unit formatting)
  • package.json and package-lock.json reviewed
  • Security reviewed (no data URIs, check for nonce leak)
  • Tests reviewed (coverage, legitimacy)

Add paste and drag-and-drop support for file attachments in the send box,
consistent across both basic and fluent themes. Users can now paste files
from the clipboard or drag files onto the chat to attach them.

- Basic theme: Add onPaste handler, DropZone component, and handleAddFiles helper
- Fluent theme: Add onPaste handler (drag-and-drop already existed)
- All file types supported, respects disableFileUpload style option

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 11, 2026 12:06
Copy link
Copy Markdown
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 adds additional file-ingestion paths to the send box so users can attach files via clipboard paste (basic + fluent themes) and drag-and-drop (basic theme via a new DropZone component), aligning these interactions with existing attachment workflows and respecting the disableFileUpload style option.

Changes:

  • Add onPaste handling to capture clipboard file attachments in both basic and fluent send boxes.
  • Introduce a new DropZone component for the basic theme to enable drag-and-drop attachments.
  • Add basic-theme attachment construction (useMakeThumbnail + useSendBoxAttachments) for dropped/pasted files.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
packages/fluent-theme/src/components/sendBox/SendBox.tsx Adds onPaste handler to attach clipboard files in the fluent send box.
packages/component/src/SendBox/DropZone.tsx New basic-theme drop zone overlay component for drag-and-drop file attachments.
packages/component/src/SendBox/BasicSendBox.tsx Adds paste handling, wires in DropZone, and adds helper to add dropped/pasted files to send box attachments.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/component/src/SendBox/BasicSendBox.tsx
Comment thread packages/component/src/SendBox/BasicSendBox.tsx
Comment thread packages/fluent-theme/src/components/sendBox/SendBox.tsx
Gary Pretty and others added 2 commits May 11, 2026 13:27
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Gate paste and drop on uiState === 'disabled' in both themes
- Respect sendAttachmentOn: 'attach' in basic theme handleAddFiles
- Hide DropZone when UI is disabled

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@compulim
Copy link
Copy Markdown
Contributor

compulim commented May 11, 2026

  • Add E2E tests
  • Use our PR template

Gary Pretty and others added 4 commits May 11, 2026 20:05
- Add pasteFile.html: tests pasting files into send box, verifies
  attachment bar shows items and multiple pastes accumulate
- Add dragAndDrop.upload.html: tests drag-and-drop flow in basic theme,
  verifies drop zone appears, files are attached on drop
- Add sendBoxDropZone test ID to basic theme DropZone component

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New tests cannot include baseline snapshot images without running in the
CI Docker environment. Use assertion-only checks instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Baseline snapshot images need to be generated in the CI Docker
environment. The tests will fail until baselines are committed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Generate baseline snapshot images for both E2E tests using Docker
  Selenium environment
- Fix pasteFile test to use text/plain files instead of fake image/png
  to avoid thumbnail decode errors in browser

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@garypretty
Copy link
Copy Markdown
Author

Updated: baseline snapshot images have been generated using the Docker Selenium environment and are now committed. Both E2E tests (pasteFile.html and dragAndDrop.upload.html) pass locally against the baselines.

Gary Pretty and others added 2 commits May 11, 2026 22:55
Previous snapshots used wrong viewport (780x441) because they bypassed
the jest-server which sets the window to 360x640. Now generated through
the jest-server proxy matching CI configuration.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

4 participants