Skip to content

Commit c3ce861

Browse files
authored
Merge pull request #4683 from GeekyAnts/fix/button-isloadingtext
fix: isloadingtext not showing option
2 parents 38a12a1 + 7c94a70 commit c3ce861

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

src/components/primitives/Button/Button.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,16 @@ const Button = (
9696
);
9797
}
9898

99-
const boxChildren = isLoading && isLoadingText ? isLoadingText : children;
100-
10199
const spinnerElement = spinner ? (
102100
spinner
103101
) : (
104102
<Spinner color={_text?.color} {..._spinner} />
105103
);
106104

105+
const boxChildren = (child: any) => {
106+
return <Box _text={_text}>{child}</Box>;
107+
};
108+
107109
return (
108110
<Pressable
109111
disabled={isDisabled || isLoading}
@@ -127,14 +129,15 @@ const Button = (
127129
{...resolvedProps}
128130
accessibilityRole={props.accessibilityRole ?? 'button'}
129131
>
130-
<HStack {..._stack}>
132+
<HStack {..._stack} test={true}>
131133
{startIcon && !isLoading ? startIcon : null}
132134
{isLoading && spinnerPlacement === 'start' ? spinnerElement : null}
133-
{boxChildren ? (
134-
<Box _text={_text}>
135-
{isLoading && isLoadingText ? isLoadingText : children}
136-
</Box>
137-
) : null}
135+
{isLoading
136+
? isLoadingText
137+
? boxChildren(isLoadingText)
138+
: null
139+
: boxChildren(children)}
140+
138141
{endIcon && !isLoading ? endIcon : null}
139142
{isLoading && spinnerPlacement === 'end' ? spinnerElement : null}
140143
</HStack>

src/theme/components/button.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@ const baseStyle = (props: any) => {
1717
flexDirection: 'row',
1818
justifyContent: 'center',
1919
alignItems: 'center',
20+
2021
_web: {
21-
cursor: props.isDisabled
22-
? 'not-allowed'
23-
: props.isLoading
24-
? 'default'
25-
: 'pointer',
22+
_disabled: {
23+
cursor: 'not-allowed',
24+
},
25+
_loading: {
26+
cursor: 'not-allowed',
27+
},
28+
cursor: 'pointer',
2629
},
2730
_text: {
2831
fontWeight: 'medium',

0 commit comments

Comments
 (0)