Skip to content

Commit 4213a86

Browse files
authored
Remove the CSS modules feature flag from the Autocomplete component (#5793)
1 parent 4e85438 commit 4213a86

File tree

4 files changed

+16
-58
lines changed

4 files changed

+16
-58
lines changed

.changeset/long-suns-type.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 Autocomplete component.

packages/react/src/Autocomplete/AutocompleteMenu.tsx

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@ import type {ActionListItemProps} from '../ActionList'
77
import {ActionList} from '../ActionList'
88
import {useFocusZone} from '../hooks/useFocusZone'
99
import type {ComponentProps, MandateProps} from '../utils/types'
10-
import Box from '../Box'
1110
import Spinner from '../Spinner'
1211
import {useId} from '../hooks/useId'
1312
import {AutocompleteContext} from './AutocompleteContext'
1413
import type {IconProps} from '@primer/octicons-react'
1514
import {PlusIcon} from '@primer/octicons-react'
1615
import VisuallyHidden from '../_VisuallyHidden'
1716
import {isElement} from 'react-is'
18-
import {useFeatureFlag} from '../FeatureFlags'
1917

2018
import classes from './AutocompleteMenu.module.css'
2119

@@ -122,8 +120,6 @@ export type AutocompleteMenuInternalProps<T extends AutocompleteItemProps> = {
122120
['aria-labelledby']: string
123121
}
124122

125-
const CSS_MODULES_FEATURE_FLAG = 'primer_react_css_modules_ga'
126-
127123
/**
128124
* Announces a message to screen readers at a slowed-down rate. This is useful when you want to announce don't want to
129125
* overwhelm the user with too many announcements in rapid succession.
@@ -345,20 +341,12 @@ function AutocompleteMenu<T extends AutocompleteItemProps>(props: AutocompleteMe
345341
throw new Error('Autocomplete: selectionVariant "single" cannot be used with multiple selected items')
346342
}
347343

348-
const enabled = useFeatureFlag(CSS_MODULES_FEATURE_FLAG)
349-
350344
return (
351345
<VisuallyHidden isVisible={showMenu}>
352346
{loading ? (
353-
enabled ? (
354-
<Box className={classes.SpinnerWrapper}>
355-
<Spinner />
356-
</Box>
357-
) : (
358-
<Box p={3} display="flex" justifyContent="center">
359-
<Spinner />
360-
</Box>
361-
)
347+
<div className={classes.SpinnerWrapper}>
348+
<Spinner />
349+
</div>
362350
) : (
363351
<div ref={listContainerRef}>
364352
{allItemsToRender.length ? (
@@ -396,11 +384,7 @@ function AutocompleteMenu<T extends AutocompleteItemProps>(props: AutocompleteMe
396384
})}
397385
</ActionList>
398386
) : emptyStateText !== false && emptyStateText !== null ? (
399-
enabled ? (
400-
<Box className={classes.EmptyStateWrapper}>{emptyStateText}</Box>
401-
) : (
402-
<Box p={3}>{emptyStateText}</Box>
403-
)
387+
<div className={classes.EmptyStateWrapper}>{emptyStateText}</div>
404388
) : null}
405389
</div>
406390
)}

packages/react/src/Autocomplete/AutocompleteOverlay.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import type {ComponentProps} from '../utils/types'
66
import {AutocompleteContext} from './AutocompleteContext'
77
import {useRefObjectAsForwardedRef} from '../hooks/useRefObjectAsForwardedRef'
88
import VisuallyHidden from '../_VisuallyHidden'
9-
import {useFeatureFlag} from '../FeatureFlags'
109

1110
import classes from './AutocompleteOverlay.module.css'
1211

@@ -50,8 +49,6 @@ function AutocompleteOverlay({
5049
setShowMenu(false)
5150
}, [setShowMenu])
5251

53-
const enabled = useFeatureFlag('primer_react_css_modules_ga')
54-
5552
if (typeof window === 'undefined') {
5653
return null
5754
}
@@ -65,14 +62,7 @@ function AutocompleteOverlay({
6562
ref={floatingElementRef as React.RefObject<HTMLDivElement>}
6663
top={position?.top}
6764
left={position?.left}
68-
sx={
69-
enabled
70-
? undefined
71-
: {
72-
overflow: 'auto',
73-
}
74-
}
75-
className={enabled ? classes.Overlay : undefined}
65+
className={classes.Overlay}
7666
{...overlayProps}
7767
>
7868
{children}

packages/react/src/__tests__/__snapshots__/Autocomplete.test.tsx.snap

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,7 @@ exports[`snapshots renders a custom empty state message 1`] = `
246246
type="text"
247247
/>
248248
</span>,
249-
.c1 {
250-
padding: 16px;
251-
}
252-
253-
.c0 {
249+
.c0 {
254250
position: absolute;
255251
width: 1px;
256252
height: 1px;
@@ -272,7 +268,7 @@ exports[`snapshots renders a custom empty state message 1`] = `
272268
>
273269
<div>
274270
<div
275-
className="c1"
271+
className="EmptyStateWrapper"
276272
>
277273
No results
278274
</div>
@@ -527,19 +523,7 @@ exports[`snapshots renders a loading state 1`] = `
527523
type="text"
528524
/>
529525
</span>,
530-
.c1 {
531-
padding: 16px;
532-
display: -webkit-box;
533-
display: -webkit-flex;
534-
display: -ms-flexbox;
535-
display: flex;
536-
-webkit-box-pack: center;
537-
-webkit-justify-content: center;
538-
-ms-flex-pack: center;
539-
justify-content: center;
540-
}
541-
542-
.c0 {
526+
.c0 {
543527
position: absolute;
544528
width: 1px;
545529
height: 1px;
@@ -560,8 +544,7 @@ exports[`snapshots renders a loading state 1`] = `
560544
className="c0"
561545
>
562546
<div
563-
className="c1"
564-
display="flex"
547+
className="SpinnerWrapper"
565548
>
566549
<span
567550
className="Box"
@@ -4916,11 +4899,7 @@ exports[`snapshots renders with an input value 1`] = `
49164899
type="text"
49174900
/>
49184901
</span>,
4919-
.c1 {
4920-
padding: 16px;
4921-
}
4922-
4923-
.c0 {
4902+
.c0 {
49244903
position: absolute;
49254904
width: 1px;
49264905
height: 1px;
@@ -4950,7 +4929,7 @@ exports[`snapshots renders with an input value 1`] = `
49504929
>
49514930
<div>
49524931
<div
4953-
className="c1"
4932+
className="EmptyStateWrapper"
49544933
>
49554934
No selectable options
49564935
</div>

0 commit comments

Comments
 (0)