Skip to content

Commit

Permalink
fix: share behavior with only URL (#920)
Browse files Browse the repository at this point in the history
share shoudl work with either URL or message

asana ticket:
https://app.asana.com/0/1207348487265909/1207728676008502/f
  • Loading branch information
rohanbayya authored Aug 2, 2024
1 parent 82caffe commit 2f2d49c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/reference_behavior_share.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ The title that appears as part of the Share UI on Android devices.
| ------ | -------- |
| string | **No** |

If the user chooses to share the content via email, this attribute pre-populate the subject of the email.
If the user chooses to share the content via email, this attribute will pre-populate the subject of the email.

### message

Expand Down
6 changes: 6 additions & 0 deletions src/behaviors/hv-share/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ const getContent = (
}
return { message };
}
if (url) {
if (title) {
return { title, url };
}
return { url };
}
return null;
};

Expand Down
4 changes: 1 addition & 3 deletions src/behaviors/hv-share/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
export type Content = {
message: string;
title?: string;
url?: string;
};
} & ({ message: string; url?: string } | { message?: string; url: string });

// copied from react-native/Share/Share.js
export type Options = {
Expand Down

0 comments on commit 2f2d49c

Please sign in to comment.