Skip to content

Conversation

@namanrajpal
Copy link
Contributor

Summary

Fixes clipboard paste behavior on iOS Safari by properly detecting text vs image content and allowing the browser to handle text paste natively.

Problem

On iOS Safari/Chrome, the synchronous event.clipboardData API doesn't reliably expose image content. The async Clipboard API (navigator.clipboard.read()) is required for reading images, but calling event.preventDefault() unconditionally breaks normal text pasting.

Solution

Implemented a two-phase paste detection for iOS:

  1. Text check first: Attempt to read text via navigator.clipboard.readText()

    • If text exists → early return to let browser handle text paste natively
    • If no text or read fails → proceed to image handling
  2. Image handling: Only preventDefault() and use async Clipboard API when clipboard doesn't contain text

Changes

  • frontend/src/components/message/PromptInput.tsx: Added iOS-specific paste detection logic that preserves native text paste behavior while enabling image paste via async Clipboard API

Testing

  • Verified text paste works on iOS Safari
  • Verified image paste works on iOS Safari
  • Verified existing paste behavior unchanged on desktop browsers

- Check for text content first using clipboard.readText()
- Only intercept paste event if no text is found
- Allows native browser text paste behavior on iOS
- Maintains file/image paste functionality
- Fixes issue where text paste was blocked on iPhone browsers
@oneishaansharma
Copy link
Contributor

oneishaansharma commented Jan 15, 2026

Thanks for the improvement. I also noticed another bug where pressing "enter" or "return" key in Safari on iOS keyboard behaves inconsistently. i.e. sometimes it adds next line char (usually the first time - leading to sending a message before I'm ready), and others it "sends" the message. Only mentioning since you're likely in the same area.

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