Skip to content

Fix Safari state share clipboard copy - #1107

Merged
chrisj merged 1 commit into
google:masterfrom
fatih-uzlmz:codex/fix-safari-state-share-clipboard
Sep 22, 2026
Merged

chrisj merged 1 commit into
google:masterfrom
fatih-uzlmz:codex/fix-safari-state-share-clipboard

Conversation

@fatih-uzlmz

Copy link
Copy Markdown
Contributor

Fixes #872.

Safari requires clipboard writes to begin within the user-activation handler. The state share flow previously called navigator.clipboard.writeText only after the state-server request completed, at which point Safari rejected it with NotAllowedError.

This change:

  • starts navigator.clipboard.write during the Share button click;
  • supplies the asynchronously generated link through a promised ClipboardItem blob;
  • displays the generated link with an explicit Copy button if automatic clipboard access is denied; and
  • adds regression coverage for pending data, state-generation failures, and clipboard failures.

Tested with:

  • npx vitest --run src/util/clipboard.spec.ts
  • npm run typecheck
  • npm run lint:check
  • npm run format:check
  • manual Safari and Chrome testing with a delayed local state-server response

@chrisj chrisj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @fatih-uzlmz

@chrisj

chrisj commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

@fatih-uzlmz was adding "displays the generated link with an explicit Copy button if automatic clipboard access is denied; and" necessary from your testing or was it added defensively? If the former, is that related to the time it takes for the state server to respond?

@chrisj
chrisj merged commit da443d2 into google:master Sep 22, 2026
29 checks passed
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.

Share state button does not copy in Safari

3 participants