Skip to content

Commit 498f88d

Browse files
authored
Revert "ref(core): button busy state and form SubmitButton UX (#109869)"
This reverts commit 2ff37ee.
1 parent e471971 commit 498f88d

File tree

6 files changed

+32
-154
lines changed

6 files changed

+32
-154
lines changed

static/app/components/core/button/button.spec.tsx

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,34 +26,6 @@ describe('Button', () => {
2626

2727
expect(spy).not.toHaveBeenCalled();
2828
});
29-
30-
it('does not call `onClick` on busy buttons', async () => {
31-
const spy = jest.fn();
32-
render(
33-
<Button onClick={spy} busy>
34-
Click me
35-
</Button>
36-
);
37-
await userEvent.click(screen.getByText('Click me'));
38-
39-
expect(spy).not.toHaveBeenCalled();
40-
});
41-
42-
it('shows spinner when busy', () => {
43-
render(<Button busy>Busy Button</Button>);
44-
45-
const button = screen.getByRole('button', {name: 'Busy Button'});
46-
expect(button).toHaveAttribute('aria-busy', 'true');
47-
expect(screen.getByRole('status', {name: 'Busy'})).not.toHaveStyle({
48-
visibility: 'hidden',
49-
});
50-
});
51-
52-
it('hides spinner when not busy', () => {
53-
render(<Button>Normal Button</Button>);
54-
55-
expect(screen.queryByRole('status', {name: 'Busy'})).not.toBeInTheDocument();
56-
});
5729
});
5830

5931
describe('LinkButton', () => {
Lines changed: 25 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import {keyframes} from '@emotion/react';
21
import styled from '@emotion/styled';
32

4-
import {Flex, Grid} from '@sentry/scraps/layout';
3+
import {Flex} from '@sentry/scraps/layout';
54
import {Tooltip} from '@sentry/scraps/tooltip';
65

76
import {IconDefaultsProvider} from 'sentry/icons/useIconDefaults';
@@ -30,13 +29,6 @@ export function Button({
3029
busy,
3130
});
3231

33-
const iconGap =
34-
props.icon && hasChildren
35-
? size === 'xs' || size === 'zero'
36-
? 'sm'
37-
: 'md'
38-
: undefined;
39-
4032
return (
4133
<Tooltip
4234
skipWrapper
@@ -56,29 +48,30 @@ export function Button({
5648
onClick={handleClick}
5749
role="button"
5850
>
59-
<Grid as="span" align="center" justifyItems="center" minWidth="0" height="100%">
60-
<Flex
61-
as="span"
62-
align="center"
63-
area="1 / 1"
64-
gap={iconGap}
65-
visibility={busy ? 'hidden' : undefined}
66-
>
67-
{props.icon && (
68-
<Flex as="span" align="center" flexShrink={0}>
69-
<IconDefaultsProvider size={BUTTON_ICON_SIZES[size]}>
70-
{props.icon}
71-
</IconDefaultsProvider>
72-
</Flex>
73-
)}
74-
{props.children}
75-
</Flex>
76-
<BusySpinner
77-
role="status"
78-
aria-label="Busy"
79-
style={busy ? undefined : {visibility: 'hidden'}}
80-
/>
81-
</Grid>
51+
<Flex
52+
as="span"
53+
align="center"
54+
justify="center"
55+
minWidth="0"
56+
height="100%"
57+
whiteSpace="nowrap"
58+
>
59+
{props.icon && (
60+
<Flex
61+
as="span"
62+
align="center"
63+
flexShrink={0}
64+
marginRight={
65+
hasChildren ? (size === 'xs' || size === 'zero' ? 'sm' : 'md') : undefined
66+
}
67+
>
68+
<IconDefaultsProvider size={BUTTON_ICON_SIZES[size]}>
69+
{props.icon}
70+
</IconDefaultsProvider>
71+
</Flex>
72+
)}
73+
{props.children}
74+
</Flex>
8275
</StyledButton>
8376
</Tooltip>
8477
);
@@ -87,24 +80,3 @@ export function Button({
8780
const StyledButton = styled('button')<ButtonProps>`
8881
${p => getButtonStyles(p as any)}
8982
`;
90-
91-
const spin = keyframes`
92-
to {
93-
transform: rotate(360deg);
94-
}
95-
`;
96-
97-
const BusySpinner = styled('span')`
98-
grid-area: 1 / 1;
99-
100-
&::after {
101-
content: '';
102-
display: block;
103-
width: 1em;
104-
height: 1em;
105-
border-radius: 50%;
106-
border: 2px solid currentColor;
107-
border-top-color: transparent;
108-
animation: ${spin} 0.6s linear infinite;
109-
}
110-
`;

static/app/components/core/button/styles.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ export function DO_NOT_USE_getButtonStyles(
132132
zIndex: 1,
133133
position: 'relative',
134134

135+
display: 'inherit',
136+
alignItems: 'inherit',
137+
justifyContent: 'inherit',
135138
flex: '1',
139+
gap: 'inherit',
136140
overflow: 'hidden',
137141

138142
whiteSpace: 'nowrap',

static/app/components/core/form/scrapsForm.spec.tsx

Lines changed: 0 additions & 65 deletions
This file was deleted.

static/app/components/core/form/scrapsForm.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,14 @@ const {useAppForm} = createFormHook({
6969
function SubmitButton(props: ButtonProps) {
7070
const form = useFormContext();
7171
return (
72-
<form.Subscribe selector={state => state.isSubmitting}>
73-
{isSubmitting => (
72+
<form.Subscribe selector={state => state.isSubmitting || state.isDefaultValue}>
73+
{isDisabled => (
7474
<Button
7575
{...props}
7676
priority="primary"
7777
type="submit"
7878
form={form.formId}
79-
busy={isSubmitting}
80-
disabled={isSubmitting || props.disabled}
79+
disabled={isDisabled || props.disabled}
8180
/>
8281
)}
8382
</form.Subscribe>

static/app/components/core/layout/container.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ interface ContainerLayoutProps {
8484
alignSelf?: Responsive<React.CSSProperties['alignSelf']>;
8585
justifySelf?: Responsive<React.CSSProperties['justifySelf']>;
8686

87-
visibility?: Responsive<'visible' | 'hidden' | 'collapse'>;
88-
8987
// Text Wrapping
9088
whiteSpace?: Responsive<
9189
'break-spaces' | 'normal' | 'nowrap' | 'pre' | 'pre-line' | 'pre-wrap'
@@ -224,7 +222,6 @@ const omitContainerProps = new Set<keyof ContainerLayoutProps | 'as'>([
224222
'right',
225223
'row',
226224
'top',
227-
'visibility',
228225
'width',
229226
'whiteSpace',
230227
]);
@@ -312,7 +309,6 @@ export const Container = styled(
312309
${p => rc('border-left', p.borderLeft, p.theme, getBorder)};
313310
${p => rc('border-right', p.borderRight, p.theme, getBorder)};
314311
315-
${p => rc('visibility', p.visibility, p.theme)};
316312
${p => rc('white-space', p.whiteSpace, p.theme)};
317313
318314
/**

0 commit comments

Comments
 (0)