Skip to content

Commit 9c421ea

Browse files
authored
Revert "Revert "[Listbox, OptionList] Right align check icons on selected list items"" (Shopify#11842)
Reverts Shopify#11838 https://admin.web.check-alignment.kyle-durand.us.spin.dev/store/shop1
1 parent b4dceab commit 9c421ea

File tree

7 files changed

+44
-37
lines changed

7 files changed

+44
-37
lines changed

.changeset/chatty-timers-marry.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris': patch
3+
---
4+
5+
Fixed layout shift for option lists within popovers

.changeset/strong-otters-fetch.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris': patch
3+
---
4+
5+
Changed selected icon position in Listbox and OptionList

polaris-react/src/components/Listbox/Listbox.stories.tsx

+2-5
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,8 @@ export function WithAction() {
102102
<Listbox.Option value="UniqueValue-2" divider>
103103
Item 2
104104
</Listbox.Option>
105-
<Listbox.Action value="ActionValue">
106-
<LegacyStack spacing="tight">
107-
<Icon source={PlusCircleIcon} tone="base" />
108-
<div>Add item</div>
109-
</LegacyStack>
105+
<Listbox.Action value="ActionValue" icon={PlusCircleIcon}>
106+
Add item
110107
</Listbox.Action>
111108
</Listbox>
112109
);

polaris-react/src/components/Listbox/components/Action/Action.module.css

-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,3 @@
66
.ActionDivider {
77
margin-bottom: var(--p-space-100);
88
}
9-
10-
.Icon {
11-
padding-right: var(--p-space-200);
12-
}

polaris-react/src/components/Listbox/components/TextOption/TextOption.tsx

+11-7
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,21 @@ export const TextOption = memo(function TextOption({
3535
isAction && styles.isAction,
3636
);
3737

38-
const optionMarkup = selected ? (
38+
const placeholder = isAction ? null : <Box width="20px" />;
39+
40+
const optionMarkup = (
3941
<Box width="100%">
40-
<InlineStack wrap={false} align="space-between" gap="200">
42+
<InlineStack wrap={false} gap="100">
43+
{selected ? (
44+
<span>
45+
<Icon source={CheckIcon} />
46+
</span>
47+
) : (
48+
placeholder
49+
)}
4150
{children}
42-
<InlineStack align="end">
43-
<Icon source={CheckIcon} />
44-
</InlineStack>
4551
</InlineStack>
4652
</Box>
47-
) : (
48-
<>{children}</>
4953
);
5054

5155
return (

polaris-react/src/components/OptionList/components/Option/Option.module.css

+1-9
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
display: flex;
2828
flex-wrap: nowrap;
29-
justify-content: space-between;
29+
gap: var(--p-space-100);
3030

3131
/* stylelint-disable-next-line selector-max-specificity -- required for focus-visible support */
3232
&.focused:focus-visible:not(:active) {
@@ -134,14 +134,6 @@
134134
align-items: flex-end;
135135
}
136136

137-
.Icon {
138-
margin-left: var(--p-space-200);
139-
140-
svg {
141-
fill: var(--p-color-icon-brand);
142-
}
143-
}
144-
145137
.Checkbox {
146138
box-sizing: border-box;
147139
display: flex;

polaris-react/src/components/OptionList/components/Option/Option.tsx

+20-12
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {classNames, variationName} from '../../../../utilities/css';
1111
import type {InlineStackProps} from '../../../InlineStack';
1212
import {InlineStack} from '../../../InlineStack';
1313
import {Checkbox as PolarisCheckbox} from '../../../Checkbox';
14+
import {Box} from '../../../Box';
1415

1516
import styles from './Option.module.css';
1617

@@ -125,20 +126,27 @@ export function Option({
125126
onBlur={toggleFocused}
126127
aria-pressed={active || select}
127128
>
128-
<>
129-
<InlineStack
130-
wrap={false}
131-
blockAlign={verticalAlignToBlockAlign(verticalAlign)}
129+
{select || active ? (
130+
<span className={styles.Icon}>
131+
<Icon source={CheckIcon} tone="base" />
132+
</span>
133+
) : (
134+
<Box width="20px" />
135+
)}
136+
<InlineStack
137+
wrap={false}
138+
blockAlign={verticalAlignToBlockAlign(verticalAlign)}
139+
>
140+
{mediaMarkup}
141+
<span
142+
style={{
143+
minWidth:
144+
typeof label === 'string' ? `${label.length}ch` : 'initial',
145+
}}
132146
>
133-
{mediaMarkup}
134147
{label}
135-
</InlineStack>
136-
{(select || active) && (
137-
<span className={styles.Icon}>
138-
<Icon source={CheckIcon} />
139-
</span>
140-
)}
141-
</>
148+
</span>
149+
</InlineStack>
142150
</button>
143151
);
144152

0 commit comments

Comments
 (0)