Skip to content

Commit

Permalink
feat(Autocomplete): Convert to CSS modules behind feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
hussam-i-am committed Dec 17, 2024
1 parent 8e481ca commit f9b17ec
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/eight-donuts-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": minor
---

Convert Autocomplete to CSS modules behind feature flag
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.Overlay {
overflow: auto;
}
16 changes: 13 additions & 3 deletions packages/react/src/Autocomplete/AutocompleteOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import type {ComponentProps} from '../utils/types'
import {AutocompleteContext} from './AutocompleteContext'
import {useRefObjectAsForwardedRef} from '../hooks/useRefObjectAsForwardedRef'
import VisuallyHidden from '../_VisuallyHidden'
import {useFeatureFlag} from '../FeatureFlags'

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

type AutocompleteOverlayInternalProps = {
/**
Expand Down Expand Up @@ -47,6 +50,8 @@ function AutocompleteOverlay({
setShowMenu(false)
}, [setShowMenu])

const enabled = useFeatureFlag('primer_react_css_modules_team')

if (typeof window === 'undefined') {
return null
}
Expand All @@ -60,9 +65,14 @@ function AutocompleteOverlay({
ref={floatingElementRef as React.RefObject<HTMLDivElement>}
top={position?.top}
left={position?.left}
sx={{
overflow: 'auto',
}}
sx={
enabled
? undefined
: {
overflow: 'auto',
}
}
className={enabled ? classes.Overlay : undefined}
{...overlayProps}
>
{children}
Expand Down

0 comments on commit f9b17ec

Please sign in to comment.