Skip to content

Commit

Permalink
Handle promise rejection in web share api
Browse files Browse the repository at this point in the history
  • Loading branch information
mlandauer committed May 16, 2024
1 parent 534fe02 commit 81ebd34
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/components/tailwind/share_button.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
'border-light-grey2': copied,
'text-green': !copied, 'text-navy': copied}"
x-on:click="if (navigator.canShare && navigator.canShare(shareData)) {
// TODO: Handle promise rejection
navigator.share(shareData)
try {
await navigator.share(shareData);
}
catch(err) {
console.log('Web share error', err);
}
} else {
navigator.clipboard.writeText('<%= @url %>');
copied = true;
Expand Down

0 comments on commit 81ebd34

Please sign in to comment.