Skip to content

fix: prevent duplicate attachment paste handling - #3651

Open
WhyRoy wants to merge 1 commit into
teableio:developfrom
WhyRoy:feat/prevent-duplicate-attachment-paste
Open

WhyRoy wants to merge 1 commit into
teableio:developfrom
WhyRoy:feat/prevent-duplicate-attachment-paste

Conversation

@WhyRoy

@WhyRoy WhyRoy commented Sep 15, 2026

Copy link
Copy Markdown

Background

When pasting an image into an attachment cell, the same browser paste event can be processed by both the attachment upload zone and the grid editor. This may result in the same image being uploaded twice.

This change makes the attachment upload zone consume file paste events after handling them, so the grid editor does not process the same file paste again. Regular text paste behavior and repeated independent pastes remain available.

Description

When a user pastes an image directly into an attachment cell, the same
clipboard event may be processed twice:

  1. The attachment upload zone handles the pasted file.
  2. The event bubbles to the grid editor, which processes the same file again.

As a result, one pasted image can appear as two uploaded attachments.

This change makes the attachment upload zone consume file paste events after
successfully handling file uploads. The event no longer reaches the grid paste
handler, preventing duplicate uploads.

Changes

  • Pass the paste event through the file upload hook.
  • Stop propagation when the attachment zone consumes a file paste.
  • Preserve all files from a multi-file paste.
  • Ignore empty paste events.
  • Keep regular text paste behavior and separate repeated pastes unchanged.
  • Add regression tests for multi-file and empty paste events.

Reproduction

  1. Open a table with an attachment field.
  2. Enter the attachment cell editor.
  3. Copy or capture an image.
  4. Press Ctrl+V.
  5. Before this fix, the same image may be added twice.

Expected Behavior

Each file in a single clipboard paste is uploaded exactly once.

Testing

  • Manually tested pasting an image into an attachment cell in a local
    development environment.
  • Verified that one pasted image creates one attachment.
  • Verified that a later independent paste creates a new attachment.
  • Verified that multi-file paste preserves all files without duplication.
  • Automated regression tests were added for file-paste consumption.

@CLAassistant

CLAassistant commented Sep 15, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@WhyRoy
WhyRoy force-pushed the feat/prevent-duplicate-attachment-paste branch from 003ba41 to 396ed56 Compare September 15, 2026 15:21
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.

2 participants