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/shaggy-states-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': minor
---

Remove the CSS modules feature flag from the ActionList/List component
27 changes: 0 additions & 27 deletions packages/react/src/ActionList/ActionList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import theme from '../theme'
import {ActionList} from '.'
import {behavesAsComponent, checkExports} from '../utils/testing'
import {BaseStyles, ThemeProvider} from '..'
import {FeatureFlags} from '../FeatureFlags'

function SimpleActionList(): JSX.Element {
return (
Expand Down Expand Up @@ -115,18 +114,6 @@ describe('ActionList', () => {
</ActionList>
)
}
const FeatureFlagElement = () => {
return (
<FeatureFlags
flags={{
primer_react_css_modules_ga: true,
}}
>
<Element />
</FeatureFlags>
)
}
expect(HTMLRender(<FeatureFlagElement />).container.querySelector('ul')).toHaveClass('test-class-name')
expect(HTMLRender(<Element />).container.querySelector('ul')).toHaveClass('test-class-name')
})

Expand All @@ -139,20 +126,6 @@ describe('ActionList', () => {
</ActionList>
)
}
const FeatureFlagElement = () => {
return (
<FeatureFlags
flags={{
primer_react_css_modules_ga: true,
}}
>
<Element />
</FeatureFlags>
)
}
expect(HTMLRender(<FeatureFlagElement />).container.querySelector('li[aria-hidden="true"]')).toHaveClass(
'test-class-name',
)
expect(HTMLRender(<Element />).container.querySelector('li[aria-hidden="true"]')).toHaveClass('test-class-name')
})

Expand Down
69 changes: 14 additions & 55 deletions packages/react/src/ActionList/List.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import React from 'react'
import type {ForwardRefComponent as PolymorphicForwardRefComponent} from '../utils/polymorphic'
import styled from 'styled-components'
import type {SxProp} from '../sx'
import sx, {merge} from '../sx'
import {ActionListContainerContext} from './ActionListContainerContext'
import {defaultSxProp} from '../utils/defaultSxProp'
import {useSlots} from '../hooks/useSlots'
Expand All @@ -12,24 +9,14 @@ import {ListContext, type ActionListProps} from './shared'
import {useProvidedRefOrCreate} from '../hooks'
import {FocusKeys, useFocusZone} from '../hooks/useFocusZone'
import {clsx} from 'clsx'
import {useFeatureFlag} from '../FeatureFlags'
import classes from './ActionList.module.css'
import {actionListCssModulesFlag} from './featureflag'

const ListBox = styled.ul<SxProp>(sx)
import {BoxWithFallback} from '../internal/components/BoxWithFallback'

export const List = React.forwardRef<HTMLUListElement, ActionListProps>(
(
{variant = 'inset', selectionVariant, showDividers = false, role, sx: sxProp = defaultSxProp, className, ...props},
forwardedRef,
): JSX.Element => {
const styles = {
margin: 0,
paddingInlineStart: 0, // reset ul styles
paddingTop: variant === 'inset' ? 2 : 0,
paddingBottom: variant === 'inset' || variant === 'horizontal-inset' ? 2 : 0,
}

const [slots, childrenWithoutSlots] = useSlots(props.children, {
heading: Heading,
})
Expand Down Expand Up @@ -59,8 +46,6 @@ export const List = React.forwardRef<HTMLUListElement, ActionListProps>(
focusOutBehavior: listRole === 'menu' ? 'wrap' : undefined,
})

const enabled = useFeatureFlag(actionListCssModulesFlag)

return (
<ListContext.Provider
value={{
Expand All @@ -72,45 +57,19 @@ export const List = React.forwardRef<HTMLUListElement, ActionListProps>(
}}
>
{slots.heading}
{enabled ? (
sxProp !== defaultSxProp ? (
<ListBox
sx={merge(styles, sxProp as SxProp)}
className={clsx(classes.ActionList, className)}
role={listRole}
aria-labelledby={ariaLabelledBy}
ref={listRef}
data-dividers={showDividers}
data-variant={variant}
{...props}
>
{childrenWithoutSlots}
</ListBox>
) : (
<ul
className={clsx(classes.ActionList, className)}
role={listRole}
aria-labelledby={ariaLabelledBy}
ref={listRef}
data-dividers={showDividers}
data-variant={variant}
{...props}
>
{childrenWithoutSlots}
</ul>
)
) : (
<ListBox
sx={merge(styles, sxProp as SxProp)}
role={listRole}
aria-labelledby={ariaLabelledBy}
{...props}
ref={listRef}
className={className}
>
{childrenWithoutSlots}
</ListBox>
)}
<BoxWithFallback
Copy link

Copilot AI May 7, 2025

Choose a reason for hiding this comment

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

The forwarded ref (forwardedRef or listRef) is no longer passed to BoxWithFallback, which may break focus management and other ref-dependent logic. Pass ref={listRef} (or forwardedRef) to ensure ref forwarding works correctly.

Copilot uses AI. Check for mistakes.
as="ul"
sx={sxProp}
Copy link

Copilot AI May 7, 2025

Choose a reason for hiding this comment

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

Default list styles (margin reset, paddingInlineStart reset, and paddingY for the inset variant) were removed when replacing ListBox. Consider merging the original styles object with sxProp (e.g., sx={merge(styles, sxProp)}) to maintain the intended resets.

Suggested change
sx={sxProp}
sx={merge(
{
margin: 0,
paddingInlineStart: 0,
...(variant === 'inset' && {paddingY: 2}),
},
sxProp,
)}

Copilot uses AI. Check for mistakes.
className={clsx(classes.ActionList, className)}
role={listRole}
aria-labelledby={ariaLabelledBy}
ref={listRef}
data-dividers={showDividers}
data-variant={variant}
{...props}
>
{childrenWithoutSlots}
</BoxWithFallback>
</ListContext.Provider>
)
},
Expand Down
Loading
Loading