Guard the pledge share clipboard fallback - #72
Draft
posthog[bot] wants to merge 1 commit into
Draft
Conversation
The pledge "Share this pledge" button could fail silently. After the native share sheet is dismissed, the handler fell through to a bare navigator.clipboard.writeText, which the browser rejects because the transient user activation is gone. The rejection surfaced as an unhandled rejection, the copied state never flipped, and the user saw no error. Move the share behaviour into a shared usePledgeShare hook that: - treats a dismissed share sheet (AbortError) as done and skips the clipboard, - wraps the clipboard write in try/catch and shows a toast on failure, matching the existing ShareButtons pattern. The four region pledge pages (Toronto, Brampton, Ottawa, Hamilton) now use the one hook instead of four copies of the same handler. Generated-By: PostHog Desktop Task-Id: 2cb29cbb-01ef-4cdf-8120-ebcaef8571e1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
navigator.clipboard.writeText. The browser rejects that write, because the transient user activation is already gone (NotAllowedError).setCopied(true)never ran — the "Link copied" state never showed.Changes
usePledgeSharehook that reports failure instead of failing silently:AbortError) is treated as done, and the clipboard fallback is skipped — the write would only reject anyway.try/catchand shows a toast on failure, the same pattern already used inShareButtons.tsx.Test plan
pnpm run lint— passes.pnpm exec tsc --noEmit— no new type errors (the pre-existing*-stamp.pngmodule errors are unrelated and also hit untouched files).Created with PostHog Desktop from this inbox report.