voyager icon indicating copy to clipboard operation
voyager copied to clipboard

Share buttons don't do anything on devices without navigator.share

Open aeharding opened this issue 2 years ago • 5 comments

e.g. desktop computer Firefox

We should probably build our own hook, useShare (or something).

It will accept exact same props as navigator.share.

If navigator.share is undefined, should copy text to clipboard (prefer URL if exists in share payload) and then present toast with useIonToast.

aeharding avatar Jul 02 '23 21:07 aeharding

I'll take a crack at this one as well, but it might be above my JS abilities. I'll update once I try it.

rsammelson avatar Jul 02 '23 22:07 rsammelson

Maybe this polyfill could be of use: https://www.npmjs.com/package/share-api-polyfill

Vishram1123 avatar Jul 05 '23 01:07 Vishram1123

I just saw that you made an edit which would copy the post/image url to the clipboard if navigator.share isn't present, but I think the share-api-polyfill would still be much more comprehensive and useful.

Vishram1123 avatar Jul 05 '23 01:07 Vishram1123

At least in my opinion, on desktop copying to clipboard is much more useful. Then I can just Super+Tab to the window I want to put the link in and paste it.

rsammelson avatar Jul 05 '23 02:07 rsammelson

Yeah, I think just copy to clipboard with a toast is best as a fallback.

aeharding avatar Jul 05 '23 02:07 aeharding