Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/famous-stingrays-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': minor
---

Deprecate connectedDisclosure prop on button
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Deprecate connectedDisclosure prop on button
Deprecated `connectedDisclosure` prop on Button

4 changes: 4 additions & 0 deletions polaris-react/src/components/Button/Button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,7 @@
}

> :first-child .Button,
> :first-child .Button::before,
> :first-child .Button::after {
border-radius: 0;
border-top-left-radius: var(--p-border-radius-1);
Expand All @@ -1453,6 +1454,7 @@
}

> :last-child .Button,
> :last-child .Button::before,
> :last-child .Button::after {
border-radius: 0;
border-top-right-radius: var(--p-border-radius-1);
Expand All @@ -1476,11 +1478,13 @@

[data-buttongroup-connected-top='true'] {
> :first-child .Button,
> :first-child .Button::before,
> :first-child .Button::after {
border-top-left-radius: 0;
}

> :last-child .Button,
> :last-child .Button::before,
> :last-child .Button::after {
border-top-right-radius: 0;
}
Expand Down
62 changes: 53 additions & 9 deletions polaris-react/src/components/Button/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ import {
VerticalStack,
Text,
Box,
Popover,
ActionList,
Divider,
} from '@shopify/polaris';
import {
PlusMinor,
DeleteMinor,
CancelSmallMinor,
EditMajor,
ChevronDownMinor,
} from '@shopify/polaris-icons';

export default {
Expand Down Expand Up @@ -717,17 +721,57 @@ export function SelectDisclosure() {
}

export function Split() {
const [active, setActive] = React.useState(false);
return (
<div style={{height: '100px'}}>
<Button
primary
connectedDisclosure={{
accessibilityLabel: 'Other save actions',
actions: [{content: 'Save as draft'}],
}}
>
Save
</Button>
<ButtonGroup segmented>
<Button primary>Save</Button>

<div style={{width: '3px'}} />

<Popover
active={active}
preferredAlignment="right"
activator={
<Button
primary
onClick={() => setActive(true)}
icon={ChevronDownMinor}
accessibilityLabel="Other save actions"
/>
}
autofocusTarget="first-node"
onClose={() => setActive(false)}
>
<ActionList
actionRole="menuitem"
items={[{content: 'Save as draft'}]}
/>
</Popover>
</ButtonGroup>

<ButtonGroup segmented>
<Button>Save</Button>

<Popover
active={active}
preferredAlignment="right"
activator={
<Button
onClick={() => setActive(true)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth keeping the primary prop here to avoid a Chromatic diff?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, I can add it 👍

icon={ChevronDownMinor}
accessibilityLabel="Other save actions"
/>
}
autofocusTarget="first-node"
onClose={() => setActive(false)}
>
<ActionList
actionRole="menuitem"
items={[{content: 'Save as draft'}]}
/>
</Popover>
</ButtonGroup>
</div>
);
}
Expand Down
2 changes: 1 addition & 1 deletion polaris-react/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export interface ButtonProps extends BaseButton {
removeUnderline?: boolean;
/** Icon to display to the left of the button content */
icon?: React.ReactElement | IconSource;
/** Disclosure button connected right of the button. Toggles a popover action list. */
/** @deprecated See the split example to replicate this prop */
connectedDisclosure?: ConnectedDisclosure;
/** Indicates whether or not the button is the primary navigation link when rendered inside of an `IndexTable.Row` */
dataPrimaryLink?: boolean;
Expand Down
58 changes: 48 additions & 10 deletions polaris.shopify.com/pages/examples/button-split.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,57 @@
import {Button} from '@shopify/polaris';
import {ActionList, Button, ButtonGroup, Popover} from '@shopify/polaris';
import React from 'react';
import {withPolarisExample} from '../../src/components/PolarisExampleWrapper';
import {ChevronDownMinor} from '@shopify/polaris-icons';

function ButtonExample() {
const [active, setActive] = React.useState(false);
return (
<div style={{height: '100px'}}>
<Button
primary
connectedDisclosure={{
accessibilityLabel: 'Other save actions',
actions: [{content: 'Save as draft'}],
}}
>
Save
</Button>
<ButtonGroup segmented>
<Button primary>Save</Button>
<div style={{width: '3px'}} />
<Popover
active={active}
preferredAlignment="right"
activator={
<Button
primary
onClick={() => setActive(true)}
icon={ChevronDownMinor}
accessibilityLabel="Other save actions"
/>
}
autofocusTarget="first-node"
onClose={() => setActive(false)}
>
<ActionList
actionRole="menuitem"
items={[{content: 'Save as draft'}]}
/>
</Popover>
</ButtonGroup>

<ButtonGroup segmented>
<Button>Save</Button>
<Popover
active={active}
preferredAlignment="right"
activator={
<Button
onClick={() => setActive(true)}
icon={ChevronDownMinor}
accessibilityLabel="Other save actions"
/>
}
autofocusTarget="first-node"
onClose={() => setActive(false)}
>
<ActionList
actionRole="menuitem"
items={[{content: 'Save as draft'}]}
/>
</Popover>
</ButtonGroup>
</div>
);
}
Expand Down