Skip to content

Commit 6c2c999

Browse files
jonrohanfrancineluccaprimer[bot]github-actions[bot]joshblack
authored
chore(ActionList): Remove the CSS modules feature flag from the ActionList/List component (#6019)
Co-authored-by: Marie Lucca <[email protected]> Co-authored-by: primer[bot] <119360173+primer[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Josh Black <[email protected]> Co-authored-by: Jamie Shark <[email protected]>
1 parent 2fc9327 commit 6c2c999

File tree

5 files changed

+865
-973
lines changed

5 files changed

+865
-973
lines changed

.changeset/shaggy-states-travel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': minor
3+
---
4+
5+
Remove the CSS modules feature flag from the ActionList/List component

packages/react/src/ActionList/ActionList.test.tsx

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import theme from '../theme'
66
import {ActionList} from '.'
77
import {behavesAsComponent, checkExports} from '../utils/testing'
88
import {BaseStyles, ThemeProvider} from '..'
9-
import {FeatureFlags} from '../FeatureFlags'
109

1110
function SimpleActionList(): JSX.Element {
1211
return (
@@ -115,18 +114,6 @@ describe('ActionList', () => {
115114
</ActionList>
116115
)
117116
}
118-
const FeatureFlagElement = () => {
119-
return (
120-
<FeatureFlags
121-
flags={{
122-
primer_react_css_modules_ga: true,
123-
}}
124-
>
125-
<Element />
126-
</FeatureFlags>
127-
)
128-
}
129-
expect(HTMLRender(<FeatureFlagElement />).container.querySelector('ul')).toHaveClass('test-class-name')
130117
expect(HTMLRender(<Element />).container.querySelector('ul')).toHaveClass('test-class-name')
131118
})
132119

@@ -139,20 +126,6 @@ describe('ActionList', () => {
139126
</ActionList>
140127
)
141128
}
142-
const FeatureFlagElement = () => {
143-
return (
144-
<FeatureFlags
145-
flags={{
146-
primer_react_css_modules_ga: true,
147-
}}
148-
>
149-
<Element />
150-
</FeatureFlags>
151-
)
152-
}
153-
expect(HTMLRender(<FeatureFlagElement />).container.querySelector('li[aria-hidden="true"]')).toHaveClass(
154-
'test-class-name',
155-
)
156129
expect(HTMLRender(<Element />).container.querySelector('li[aria-hidden="true"]')).toHaveClass('test-class-name')
157130
})
158131

packages/react/src/ActionList/List.tsx

Lines changed: 14 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import React from 'react'
22
import type {ForwardRefComponent as PolymorphicForwardRefComponent} from '../utils/polymorphic'
3-
import styled from 'styled-components'
4-
import type {SxProp} from '../sx'
5-
import sx, {merge} from '../sx'
63
import {ActionListContainerContext} from './ActionListContainerContext'
74
import {defaultSxProp} from '../utils/defaultSxProp'
85
import {useSlots} from '../hooks/useSlots'
@@ -12,24 +9,14 @@ import {ListContext, type ActionListProps} from './shared'
129
import {useProvidedRefOrCreate} from '../hooks'
1310
import {FocusKeys, useFocusZone} from '../hooks/useFocusZone'
1411
import {clsx} from 'clsx'
15-
import {useFeatureFlag} from '../FeatureFlags'
1612
import classes from './ActionList.module.css'
17-
import {actionListCssModulesFlag} from './featureflag'
18-
19-
const ListBox = styled.ul<SxProp>(sx)
13+
import {BoxWithFallback} from '../internal/components/BoxWithFallback'
2014

2115
export const List = React.forwardRef<HTMLUListElement, ActionListProps>(
2216
(
2317
{variant = 'inset', selectionVariant, showDividers = false, role, sx: sxProp = defaultSxProp, className, ...props},
2418
forwardedRef,
2519
): JSX.Element => {
26-
const styles = {
27-
margin: 0,
28-
paddingInlineStart: 0, // reset ul styles
29-
paddingTop: variant === 'inset' ? 2 : 0,
30-
paddingBottom: variant === 'inset' || variant === 'horizontal-inset' ? 2 : 0,
31-
}
32-
3320
const [slots, childrenWithoutSlots] = useSlots(props.children, {
3421
heading: Heading,
3522
})
@@ -59,8 +46,6 @@ export const List = React.forwardRef<HTMLUListElement, ActionListProps>(
5946
focusOutBehavior: listRole === 'menu' ? 'wrap' : undefined,
6047
})
6148

62-
const enabled = useFeatureFlag(actionListCssModulesFlag)
63-
6449
return (
6550
<ListContext.Provider
6651
value={{
@@ -72,45 +57,19 @@ export const List = React.forwardRef<HTMLUListElement, ActionListProps>(
7257
}}
7358
>
7459
{slots.heading}
75-
{enabled ? (
76-
sxProp !== defaultSxProp ? (
77-
<ListBox
78-
sx={merge(styles, sxProp as SxProp)}
79-
className={clsx(classes.ActionList, className)}
80-
role={listRole}
81-
aria-labelledby={ariaLabelledBy}
82-
ref={listRef}
83-
data-dividers={showDividers}
84-
data-variant={variant}
85-
{...props}
86-
>
87-
{childrenWithoutSlots}
88-
</ListBox>
89-
) : (
90-
<ul
91-
className={clsx(classes.ActionList, className)}
92-
role={listRole}
93-
aria-labelledby={ariaLabelledBy}
94-
ref={listRef}
95-
data-dividers={showDividers}
96-
data-variant={variant}
97-
{...props}
98-
>
99-
{childrenWithoutSlots}
100-
</ul>
101-
)
102-
) : (
103-
<ListBox
104-
sx={merge(styles, sxProp as SxProp)}
105-
role={listRole}
106-
aria-labelledby={ariaLabelledBy}
107-
{...props}
108-
ref={listRef}
109-
className={className}
110-
>
111-
{childrenWithoutSlots}
112-
</ListBox>
113-
)}
60+
<BoxWithFallback
61+
as="ul"
62+
sx={sxProp}
63+
className={clsx(classes.ActionList, className)}
64+
role={listRole}
65+
aria-labelledby={ariaLabelledBy}
66+
ref={listRef}
67+
data-dividers={showDividers}
68+
data-variant={variant}
69+
{...props}
70+
>
71+
{childrenWithoutSlots}
72+
</BoxWithFallback>
11473
</ListContext.Provider>
11574
)
11675
},

0 commit comments

Comments
 (0)