Skip to content

Comments

fix(useClipboard): add readonly attribute to textarea fallback to support Safari 15#5179

Merged
antfu merged 1 commit intovueuse:mainfrom
huajianjiu:fix/clipboard-safari-readonly
Nov 26, 2025
Merged

fix(useClipboard): add readonly attribute to textarea fallback to support Safari 15#5179
antfu merged 1 commit intovueuse:mainfrom
huajianjiu:fix/clipboard-safari-readonly

Conversation

@huajianjiu
Copy link
Contributor

Fixes #5178

This PR fixes a compatibility issue in old Safari (<=15.6) where
document.execCommand('copy') does not work if the textarea used
for fallback copy is editable.

Safari requires the textarea to be readonly in order to allow
select() + execCommand('copy') to succeed.

Adding:

ta.setAttribute('readonly', '')

resolves the issue on macOS 10.15.7 Safari 15.6.1 and does not
affect behavior on other browsers.

Tested in Chrome, Firefox, and Safari 17.

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Nov 21, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Nov 21, 2025
@antfu antfu enabled auto-merge November 26, 2025 01:33
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 26, 2025

Open in StackBlitz

@vueuse/components

npm i https://pkg.pr.new/@vueuse/components@5179

@vueuse/core

npm i https://pkg.pr.new/@vueuse/core@5179

@vueuse/electron

npm i https://pkg.pr.new/@vueuse/electron@5179

@vueuse/firebase

npm i https://pkg.pr.new/@vueuse/firebase@5179

@vueuse/integrations

npm i https://pkg.pr.new/@vueuse/integrations@5179

@vueuse/math

npm i https://pkg.pr.new/@vueuse/math@5179

@vueuse/metadata

npm i https://pkg.pr.new/@vueuse/metadata@5179

@vueuse/nuxt

npm i https://pkg.pr.new/@vueuse/nuxt@5179

@vueuse/router

npm i https://pkg.pr.new/@vueuse/router@5179

@vueuse/rxjs

npm i https://pkg.pr.new/@vueuse/rxjs@5179

@vueuse/shared

npm i https://pkg.pr.new/@vueuse/shared@5179

commit: fe17d55

@codecov
Copy link

codecov bot commented Nov 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.97%. Comparing base (62dfb80) to head (fe17d55).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5179   +/-   ##
=======================================
  Coverage   63.97%   63.97%           
=======================================
  Files         343      343           
  Lines        7841     7842    +1     
  Branches     2425     2413   -12     
=======================================
+ Hits         5016     5017    +1     
  Misses       2286     2286           
  Partials      539      539           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@antfu antfu added this pull request to the merge queue Nov 26, 2025
Merged via the queue into vueuse:main with commit ef0c4f8 Nov 26, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG | useClipboard | execCommand fallback fails on Safari 15 unless textarea is readonly

3 participants