File tree 1 file changed +18
-10
lines changed
packages/bento-design-system/src/ReadOnlyField
1 file changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -12,12 +12,18 @@ type Props = Omit<
12
12
"onChange" | "onBlur" | "disabled" | "isReadOnly" | "placeholder" | "issues"
13
13
> &
14
14
(
15
- | {
15
+ | ( {
16
16
withCopyButton : true ;
17
17
copyButtonLabel : LocalizedString ;
18
- copySuccessMessage : LocalizedString ;
19
- showToastOnCopy ?: boolean ;
20
- }
18
+ } & (
19
+ | {
20
+ copySuccessMessage : LocalizedString ;
21
+ showToastOnCopy : true ;
22
+ }
23
+ | {
24
+ showToastOnCopy ?: false ;
25
+ }
26
+ ) )
21
27
| {
22
28
withCopyButton ?: false ;
23
29
}
@@ -36,14 +42,16 @@ export function ReadOnlyField(props: Props) {
36
42
< IconButton
37
43
icon = { config . copyIcon }
38
44
onPress = { async ( ) => {
39
- if ( props . showToastOnCopy ?? true ) {
45
+ if ( props . withCopyButton ) {
40
46
try {
41
47
await navigator . clipboard . writeText ( props . value ) ;
42
- showToast ( {
43
- kind : "informative" ,
44
- message : props . copySuccessMessage ,
45
- dismissable : true ,
46
- } ) ;
48
+ if ( props . showToastOnCopy ) {
49
+ showToast ( {
50
+ kind : "informative" ,
51
+ message : props . copySuccessMessage ,
52
+ dismissable : true ,
53
+ } ) ;
54
+ }
47
55
} catch {
48
56
console . error ( "Could not copy to clipboard" ) ;
49
57
}
You can’t perform that action at this time.
0 commit comments