Skip to content

Guard Copy action when ClipboardItem is missing#14

Open
schickling wants to merge 1 commit into
corsfix:mainfrom
schickling:livestore/clipboarditem-fallback
Open

Guard Copy action when ClipboardItem is missing#14
schickling wants to merge 1 commit into
corsfix:mainfrom
schickling:livestore/clipboarditem-fallback

Conversation

@schickling

Copy link
Copy Markdown
Contributor

Summary

  • add feature detection before instantiating ClipboardItem
  • fall back to navigator.clipboard.writeText for browsers that do not expose the constructor (e.g. Firefox/Safari)
  • keep existing behaviour for browsers that support ClipboardItem

Testing

  • Verified the Copy Page button in a local Starlight site on Firefox 130

@reynaldichernando

Copy link
Copy Markdown
Member

thanks for the PR!
please give me some time to test this, since i don't have firefox installed, plus to make sure it doesn't break on other browser

safari is notoriously hard to do copy to clipboard

@reynaldichernando

Copy link
Copy Markdown
Member

quick update on the PR: this breaks copy in safari
let me have a look on how to do this properly while still supporting the navigator fallback

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