Skip to content

Commit f7f3718

Browse files
authored
Revert "[Listbox, OptionList] Right align check icons on selected list items" (Shopify#11838)
Reverts Shopify#11697 Need to better accommodate custom elements within list items
1 parent d5cb5ea commit f7f3718

File tree

7 files changed

+37
-44
lines changed

7 files changed

+37
-44
lines changed

.changeset/chatty-timers-marry.md

-5
This file was deleted.

.changeset/strong-otters-fetch.md

-5
This file was deleted.

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

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

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

+4
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@
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

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

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

5551
return (

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

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

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

3131
/* stylelint-disable-next-line selector-max-specificity -- required for focus-visible support */
3232
&.focused:focus-visible:not(:active) {
@@ -134,6 +134,14 @@
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+
137145
.Checkbox {
138146
box-sizing: border-box;
139147
display: flex;

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

+12-20
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ 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';
1514

1615
import styles from './Option.module.css';
1716

@@ -126,27 +125,20 @@ export function Option({
126125
onBlur={toggleFocused}
127126
aria-pressed={active || select}
128127
>
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-
}}
128+
<>
129+
<InlineStack
130+
wrap={false}
131+
blockAlign={verticalAlignToBlockAlign(verticalAlign)}
146132
>
133+
{mediaMarkup}
147134
{label}
148-
</span>
149-
</InlineStack>
135+
</InlineStack>
136+
{(select || active) && (
137+
<span className={styles.Icon}>
138+
<Icon source={CheckIcon} />
139+
</span>
140+
)}
141+
</>
150142
</button>
151143
);
152144

0 commit comments

Comments
 (0)