Skip to content

Commit

Permalink
fix(button): mistake adding variant as children
Browse files Browse the repository at this point in the history
  • Loading branch information
erick-martins committed Feb 19, 2024
1 parent 146737e commit 5d46181
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/components/__tests__/button.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,12 @@ describe('Forms > Button', () => {
expect(getByTestId(testID)).toBeTruthy();
expect(getByText('Test')).toBeTruthy();
});

it('should add children', async () => {
const { getByTestId, getByText } = renderWithProviders(
<Button testID={testID}>Test</Button>
);
expect(getByTestId(testID)).toBeTruthy();
expect(getByText('Test')).toBeTruthy();
});
});
7 changes: 4 additions & 3 deletions src/components/button/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const Button: React.FC<ButtonProps> = ({
inverted,
onPressIn,
onPressOut,
children,
...props
}) => {
const [iconColor, pressableProps] = useIconColor(buttonTheme.variants, {
Expand All @@ -20,9 +21,9 @@ export const Button: React.FC<ButtonProps> = ({
});

const _isLoadingText = useMemo(() => {
if (props.isLoading) return props.children as string;
if (props.isLoading) return children as string;
return undefined;
}, [props.isLoading, props.children]);
}, [props.isLoading, children]);

return (
<NBButton
Expand All @@ -46,7 +47,7 @@ export const Button: React.FC<ButtonProps> = ({
isLoadingText={_isLoadingText}
spinnerPlacement="end"
>
{props.variant}
{children}
</NBButton>
);
};

0 comments on commit 5d46181

Please sign in to comment.