Skip to content

Commit 30fe515

Browse files
Remove UNSAFE_ from isPending prop and enable docs (#5150)
* remove UNSAFE_ from isPending prop and enable docs * Add beta badge Co-authored-by: Robert Snow <rsnow@adobe.com> * Add import for beta badge --------- Co-authored-by: Robert Snow <rsnow@adobe.com>
1 parent a53d25c commit 30fe515

File tree

5 files changed

+26
-28
lines changed

5 files changed

+26
-28
lines changed

packages/@react-spectrum/button/docs/Button.mdx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {Layout} from '@react-spectrum/docs';
1111
export default Layout;
1212

1313
import docs from 'docs:@react-spectrum/button';
14-
import {HeaderInfo, PropTable, PageDescription} from '@react-spectrum/docs';
14+
import {HeaderInfo, PropTable, PageDescription, VersionBadge} from '@react-spectrum/docs';
1515
import packageData from '@react-spectrum/button/package.json';
1616

1717
```jsx import
@@ -83,8 +83,8 @@ function Example() {
8383
);
8484
}
8585
```
86-
{/*
87-
## Pending
86+
87+
## Pending <VersionBadge version="beta" style={{marginLeft: 4, verticalAlign: 'bottom'}} />
8888

8989
Buttons can indicate that a quick progress task is taking place (e.g., saving settings on a server). After a 1 second delay, an indeterminate spinner will be displayed in place of the button label and icon. You can trigger this behavior with the `isPending` prop. Button events are disabled while `isPending` is true.
9090

@@ -103,11 +103,10 @@ function Example() {
103103
};
104104

105105
return (
106-
<Button variant="primary" UNSTABLE_isPending={isLoading} onPress={handlePress}>Click me!</Button>
106+
<Button variant="primary" isPending={isLoading} onPress={handlePress}>Click me!</Button>
107107
);
108108
}
109109
```
110-
*/}
111110

112111
## Props
113112

packages/@react-spectrum/button/src/Button.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ import {useLocalizedStringFormatter} from '@react-aria/i18n';
3434
import {useProviderProps} from '@react-spectrum/provider';
3535

3636
function disablePendingProps(props) {
37-
// Don't allow interaction while UNSTABLE_isPending is true
38-
if (props.UNSTABLE_isPending) {
37+
// Don't allow interaction while isPending is true
38+
if (props.isPending) {
3939
props.onPress = undefined;
4040
props.onPressStart = undefined;
4141
props.onPressEnd = undefined;
@@ -60,7 +60,7 @@ function Button<T extends ElementType = 'button'>(props: SpectrumButtonProps<T>,
6060
style = variant === 'accent' || variant === 'cta' ? 'fill' : 'outline',
6161
staticColor,
6262
isDisabled,
63-
UNSTABLE_isPending,
63+
isPending,
6464
autoFocus,
6565
...otherProps
6666
} = props;
@@ -76,20 +76,20 @@ function Button<T extends ElementType = 'button'>(props: SpectrumButtonProps<T>,
7676
useEffect(() => {
7777
let timeout: ReturnType<typeof setTimeout>;
7878

79-
if (UNSTABLE_isPending) {
80-
// Start timer when UNSTABLE_isPending is set to true.
79+
if (isPending) {
80+
// Start timer when isPending is set to true.
8181
timeout = setTimeout(() => {
8282
setIsProgressVisible(true);
8383
}, 1000);
8484
} else {
85-
// Exit loading state when UNSTABLE_isPending is set to false. */
85+
// Exit loading state when isPending is set to false. */
8686
setIsProgressVisible(false);
8787
}
8888
return () => {
89-
// Clean up on unmount or when user removes UNSTABLE_isPending prop before entering loading state.
89+
// Clean up on unmount or when user removes isPending prop before entering loading state.
9090
clearTimeout(timeout);
9191
};
92-
}, [UNSTABLE_isPending]);
92+
}, [isPending]);
9393

9494
if (variant === 'cta') {
9595
variant = 'accent';
@@ -107,8 +107,8 @@ function Button<T extends ElementType = 'button'>(props: SpectrumButtonProps<T>,
107107
data-variant={variant}
108108
data-style={style}
109109
data-static-color={staticColor || undefined}
110-
aria-disabled={UNSTABLE_isPending || undefined}
111-
aria-live={UNSTABLE_isPending ? 'polite' : undefined}
110+
aria-disabled={isPending || undefined}
111+
aria-live={isPending ? 'polite' : undefined}
112112
className={
113113
classNames(
114114
styles,

packages/@react-spectrum/button/stories/Button.stories.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export default {
6666
control: 'select',
6767
options: ['white', 'black']
6868
},
69-
UNSTABLE_isPending: {
69+
isPending: {
7070
control: 'boolean',
7171
defaultValue: false
7272
}
@@ -286,27 +286,27 @@ function Pending(props) {
286286
<Flex wrap="wrap">
287287
<PendingButtonContainerComponent {...props}>
288288
<TooltipTrigger offset={2}>
289-
<Button {...props} aria-label="Notifications" onPress={() => {window.alert('use storybook control to change this button UNSTABLE_isPending prop');}}>
289+
<Button {...props} aria-label="Notifications" onPress={() => {window.alert('use storybook control to change this button isPending prop');}}>
290290
<Bell />
291291
</Button>
292292
<Tooltip>Notifications</Tooltip>
293293
</TooltipTrigger>
294294
</PendingButtonContainerComponent>
295295

296296
<PendingButtonContainerComponent {...props}>
297-
<Button {...props} aria-label="No tooltip" onPress={() => {window.alert('use storybook control to change this button UNSTABLE_isPending prop');}}>
297+
<Button {...props} aria-label="No tooltip" onPress={() => {window.alert('use storybook control to change this button isPending prop');}}>
298298
<Bell />
299299
</Button>
300300
</PendingButtonContainerComponent>
301301

302302
<PendingButtonContainerComponent {...props}>
303-
<Button {...props} onPress={() => {window.alert('use storybook control to change this button UNSTABLE_isPending prop');}}>
303+
<Button {...props} onPress={() => {window.alert('use storybook control to change this button isPending prop');}}>
304304
<Bell />
305305
</Button>
306306
</PendingButtonContainerComponent>
307307

308308
<PendingButtonContainerComponent {...props}>
309-
<Button {...props} UNSTABLE_isPending={props.UNSTABLE_isPending} onPress={() => {window.alert('use storybook control to change this button UNSTABLE_isPending prop');}}>
309+
<Button {...props} isPending={props.isPending} onPress={() => {window.alert('use storybook control to change this button isPending prop');}}>
310310
<Text>Controlled pending</Text>
311311
</Button>
312312
</PendingButtonContainerComponent>
@@ -316,7 +316,7 @@ function Pending(props) {
316316
}
317317
let timerValue = 5000;
318318
function PendingButtonComponent(props) {
319-
let [UNSTABLE_isPending, setPending] = useState(false);
319+
let [isPending, setPending] = useState(false);
320320

321321
let handlePress = (e) => {
322322
action('press')(e);
@@ -329,15 +329,15 @@ function PendingButtonComponent(props) {
329329
return (
330330
<Button
331331
{...props}
332-
UNSTABLE_isPending={UNSTABLE_isPending}
332+
isPending={isPending}
333333
onPress={handlePress}>
334334
{props.children}
335335
</Button>
336336
);
337337
}
338338

339339
function PendingButtonOnClickComponent(props) {
340-
let [UNSTABLE_isPending, setPending] = useState(false);
340+
let [isPending, setPending] = useState(false);
341341

342342
let handlePress = (e) => {
343343
action('click')(e);
@@ -350,7 +350,7 @@ function PendingButtonOnClickComponent(props) {
350350
return (
351351
<Button
352352
{...props}
353-
UNSTABLE_isPending={UNSTABLE_isPending}
353+
isPending={isPending}
354354
onClick={handlePress}>
355355
{props.children}
356356
</Button>

packages/@react-spectrum/button/test/Button.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ describe('Button', function () {
289289
setPending(true);
290290
onPressSpy();
291291
}}
292-
UNSTABLE_isPending={pending}>
292+
isPending={pending}>
293293
Click Me
294294
</Button>
295295
);
@@ -317,7 +317,7 @@ describe('Button', function () {
317317
// isPending anchor element
318318
it('removes href attribute from anchor element when isPending is true', () => {
319319
let {getByRole} = render(
320-
<Button elementType="a" href="//example.com" UNSTABLE_isPending>
320+
<Button elementType="a" href="//example.com" isPending>
321321
Click Me
322322
</Button>
323323
);

packages/@react-types/button/src/index.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,8 @@ export interface SpectrumButtonProps<T extends ElementType = 'button'> extends A
7676
staticColor?: 'white' | 'black',
7777
/**
7878
* Whether to disable events immediately and display a loading spinner after a 1 second delay.
79-
* @private
8079
*/
81-
UNSTABLE_isPending?: boolean,
80+
isPending?: boolean,
8281
/**
8382
* Whether the button should be displayed with a quiet style.
8483
* @deprecated

0 commit comments

Comments
 (0)