fix: handle clipboard API failure in CopyButton (fixes #172) - #177
fix: handle clipboard API failure in CopyButton (fixes #172)#177slsgzs-cloud wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Thank you for the contribution, couple things before this can merge, per the issue:
-
Improve the clipboard failure message
The failure case needs a short message asking the user to select and copy the command manually.
The command is already selectable, but showing only
Copy failedon the button doesn't tell the user what to do next. -
Add Playwright regression coverage
Please add regression cases to
web/e2e/funnel.spec.tscovering:- Successful copy
- Rejected clipboard write
- Unavailable Clipboard API
- Successful retry after a failure
Please override the browser Clipboard API in the tests so the cases are deterministic.
The existing landing-page test in that spec is a good pattern to follow.
-
Sign off the commit and document checks
Please sign off the commit as described in
CONTRIBUTING.md:git commit -s
Also update the PR body with the checks you ran from
web/:build:wasmtypecheckbuild- Playwright
Happy to re review once those are in.
Fixes #172
The
CopyButtonon the landing page callednavigator.clipboard.writeText()without checking availability or handling rejection. When the clipboard API was unavailable (e.g., non-secure context) or the write was rejected (e.g., permissions), the user got no feedback and the handler threw or left an unhandled rejection.Changes:
statusstate (idle/copied/failed) replacing the booleancopiednavigator.clipboardbeing undefinedtry/catchthe write to surface failuresCopy failedfor 2 seconds when the write fails, falling back toCopyon timeout (same 2s behavior as the success case)Copiedappears for 2s then resets