Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[@mantine/core] Button: Button is disabled when inside fieldset disabled #2440

Merged
merged 4 commits into from Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/mantine-core/src/Button/Button.story.tsx
Expand Up @@ -128,6 +128,16 @@ export function States() {
);
}

/**
* All buttons should be disabled
*/
export function StatesInFieldsetDisabled() {
return (
<fieldset disabled>
<States />
</fieldset>
);
}
export function CustomComponent() {
return (
<div style={{ padding: 40 }}>
Expand Down
9 changes: 9 additions & 0 deletions src/mantine-core/src/Button/Button.styles.ts
Expand Up @@ -135,6 +135,15 @@ export default createStyles(

'&:active': theme.activeStyles,

'&:disabled': {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be &:disabled, &[data-disabled] to avoid styles duplication

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rtivital sure I will add this to ActionIcon too.

Should I be adding this as a new style (as in this screenshot) or simply updating the existing style (the one marked 2 in screenshot):
image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the existing one

borderColor: 'transparent',
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[4] : theme.colors.gray[2],
color: theme.colorScheme === 'dark' ? theme.colors.dark[6] : theme.colors.gray[5],
cursor: 'not-allowed',
backgroundImage: 'none',
pointerEvents: 'none',
},

'&[data-disabled]': {
borderColor: 'transparent',
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[4] : theme.colors.gray[2],
Expand Down
9 changes: 9 additions & 0 deletions src/mantine-core/src/Button/Button.test.tsx
Expand Up @@ -52,4 +52,13 @@ describe('@mantine/core/Button', () => {
it('exposes ButtonGroup as static component', () => {
expect(Button.Group).toBe(ButtonGroup);
});

it('is disabled when inside fieldset disabled', () => {
render(
<fieldset disabled>
<Button type="submit" />
</fieldset>
);
expect(screen.getByRole('button')).toBeDisabled();
});
});