Skip to content

Commit 445b5d5

Browse files
hectahertzjonrohanfrancinelucca
authored
Fix extra padding on SelectPanel with groups (#5869)
Co-authored-by: hectahertz <24622853+hectahertz@users.noreply.github.com> Co-authored-by: Jon Rohan <yes@jonrohan.codes> Co-authored-by: Marie Lucca <francinelucca@github.com> Co-authored-by: Marie Lucca <40550942+francinelucca@users.noreply.github.com>
1 parent b03f78f commit 445b5d5

File tree

32 files changed

+16
-8
lines changed

32 files changed

+16
-8
lines changed

.changeset/fresh-lights-wink.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': patch
3+
---
4+
5+
Fix extra padding on SelectPanel with groups

packages/react/src/ActionList/ActionList.docs.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
},
1616
{
1717
"name": "variant",
18-
"type": "'inset' | 'full'",
18+
"type": "'inset' | 'horizontal-inset' | 'full'",
1919
"defaultValue": "'inset'",
20-
"description": "`inset` children are offset (vertically and horizontally) from list edges. `full` children are flush (vertically and horizontally) with list edges"
20+
"description": "`inset` children are offset (vertically and/or horizontally) from list edges. `full` children are flush (vertically and horizontally) with list edges"
2121
},
2222
{
2323
"name": "selectionVariant",

packages/react/src/ActionList/ActionList.module.css

+2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313

1414
&:where([data-variant='inset']) {
1515
padding-block: var(--base-size-8);
16+
}
1617

18+
&:where([data-variant='inset'], [data-variant='horizontal-inset']) {
1719
/* this is only to match default experience */
1820
& .ActionListItem {
1921
margin-inline: var(--base-size-8);

packages/react/src/ActionList/ActionList.stories.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Playground.argTypes = {
4545
control: {
4646
type: 'radio',
4747
},
48-
options: ['inset', 'full'],
48+
options: ['inset', 'horizontal-inset', 'full'],
4949
},
5050
selectionVariant: {
5151
control: {

packages/react/src/ActionList/Heading.module.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
margin-inline-start: var(--base-size-8);
66
}
77

8-
&:where([data-list-variant='inset']) {
8+
&:where([data-list-variant='inset'], [data-list-variant='horizontal-inset']) {
99
/* stylelint-disable-next-line primer/spacing */
1010
margin-inline-start: calc(var(--control-medium-paddingInline-condensed) + var(--base-size-8));
1111
}

packages/react/src/ActionList/Item.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ export const Item = React.forwardRef<HTMLLIElement, ActionListItemProps>(
193193
paddingY: '6px', // custom value off the scale
194194
lineHeight: '16px',
195195
minHeight: 5,
196-
marginX: listVariant === 'inset' ? 2 : 0,
196+
marginX: listVariant === 'inset' || listVariant === 'horizontal-inset' ? 2 : 0,
197197
borderRadius: 2,
198198
transition: 'background 33.333ms linear',
199199
color: getVariantStyles(variant, disabled, inactive || loading).color,
@@ -217,7 +217,7 @@ export const Item = React.forwardRef<HTMLLIElement, ActionListItemProps>(
217217
appearance: 'none',
218218
background: 'unset',
219219
border: 'unset',
220-
width: listVariant === 'inset' ? 'calc(100% - 16px)' : '100%',
220+
width: listVariant === 'inset' || listVariant === 'horizontal-inset' ? 'calc(100% - 16px)' : '100%',
221221
fontFamily: 'unset',
222222
textAlign: 'unset',
223223
marginY: 'unset',

packages/react/src/ActionList/shared.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export type ActionListProps = React.PropsWithChildren<{
120120
/**
121121
* `inset` children are offset (vertically and horizontally) from `List`’s edges, `full` children are flush (vertically and horizontally) with `List` edges
122122
*/
123-
variant?: 'inset' | 'full'
123+
variant?: 'inset' | 'horizontal-inset' | 'full'
124124
/**
125125
* Whether multiple Items or a single Item can be selected.
126126
*/

packages/react/src/SelectPanel/SelectPanel.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ function Panel({
608608
onInputRefChanged={onInputRefChanged}
609609
placeholderText={placeholderText}
610610
{...listProps}
611+
variant={listProps.groupMetadata?.length ? 'horizontal-inset' : 'inset'}
611612
role="listbox"
612613
// browsers give aria-labelledby precedence over aria-label so we need to make sure
613614
// we don't accidentally override props.aria-label

packages/react/src/deprecated/ActionList/List.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export interface ListPropsBase {
6262
* - `"inset"` - `List` children are offset (vertically and horizontally) from `List`’s edges
6363
* - `"full"` - `List` children are flush (vertically and horizontally) with `List` edges
6464
*/
65-
variant?: 'inset' | 'full'
65+
variant?: 'inset' | 'horizontal-inset' | 'full'
6666

6767
/**
6868
* For `Item`s which can be selected, whether `multiple` `Item`s or a `single` `Item` can be selected

0 commit comments

Comments
 (0)