Skip to content

Commit 957626c

Browse files
committed
Add overlay props to Autocomplete.Overlay
1 parent 77e123f commit 957626c

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/Autocomplete/AutocompleteOverlay.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,20 @@ type AutocompleteOverlayInternalProps = {
1515
*/
1616
overlayProps?: Partial<OverlayProps>
1717
children?: React.ReactNode
18-
} & Pick<React.AriaAttributes, 'aria-labelledby'> // TODO: consider making 'aria-labelledby' required
18+
} & Partial<OverlayProps> &
19+
Pick<React.AriaAttributes, 'aria-labelledby'> // TODO: consider making 'aria-labelledby' required
1920

20-
function AutocompleteOverlay({menuAnchorRef, overlayProps, children}: AutocompleteOverlayInternalProps) {
21+
function AutocompleteOverlay({
22+
menuAnchorRef,
23+
overlayProps: oldOverlayProps,
24+
children,
25+
...newOverlayProps
26+
}: AutocompleteOverlayInternalProps) {
2127
const autocompleteContext = useContext(AutocompleteContext)
2228
if (autocompleteContext === null) {
2329
throw new Error('AutocompleteContext returned null values')
2430
}
31+
const overlayProps = {...oldOverlayProps, ...newOverlayProps}
2532
const {inputRef, scrollContainerRef, selectedItemLength, setShowMenu, showMenu = false} = autocompleteContext
2633
const {floatingElementRef, position} = useAnchoredPosition(
2734
{

src/stories/Autocomplete.stories.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -558,12 +558,7 @@ export const WithCustomOverlayProps = () => {
558558
</Text>
559559
<Autocomplete>
560560
<Autocomplete.Input id="autocompleteInput" />
561-
<Autocomplete.Overlay
562-
overlayProps={{
563-
width: 'large',
564-
height: 'xsmall'
565-
}}
566-
>
561+
<Autocomplete.Overlay width="large" height="xsmall">
567562
<Autocomplete.Menu items={items} selectedItemIds={[]} aria-labelledby="autocompleteLabel" />
568563
</Autocomplete.Overlay>
569564
</Autocomplete>

0 commit comments

Comments
 (0)