Skip to content

Commit 6f0535d

Browse files
authored
Expose textInputProps from SelectPanel (#1311)
1 parent 528e9a4 commit 6f0535d

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

.changeset/brown-glasses-fix.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/components': patch
3+
---
4+
5+
Expose 'textInputProps' from the 'SelectPanel'

src/SelectPanel/SelectPanel.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ const focusZoneSettings: Partial<FocusZoneHookSettings> = {
4646
disabled: true
4747
}
4848

49-
const textInputProps: Partial<TextInputProps> = {
50-
mx: 2,
51-
my: 2,
52-
contrast: true
53-
}
54-
5549
export function SelectPanel({
5650
open,
5751
onOpenChange,
@@ -62,6 +56,7 @@ export function SelectPanel({
6256
filterValue: externalFilterValue,
6357
onFilterChange: externalOnFilterChange,
6458
items,
59+
textInputProps,
6560
overlayProps,
6661
...listProps
6762
}: SelectPanelProps): JSX.Element {
@@ -132,6 +127,15 @@ export function SelectPanel({
132127
initialFocusRef: inputRef
133128
}
134129

130+
const extendedTextInputProps: Partial<TextInputProps> = useMemo(() => {
131+
return {
132+
mx: 2,
133+
my: 2,
134+
contrast: true,
135+
...textInputProps
136+
}
137+
}, [textInputProps])
138+
135139
return (
136140
<AnchoredOverlay
137141
renderAnchor={renderMenuAnchor}
@@ -150,7 +154,7 @@ export function SelectPanel({
150154
role="listbox"
151155
items={itemsToRender}
152156
selectionVariant={isMultiSelectVariant(selected) ? 'multiple' : 'single'}
153-
textInputProps={textInputProps}
157+
textInputProps={extendedTextInputProps}
154158
inputRef={inputRef}
155159
/>
156160
</Flex>

0 commit comments

Comments
 (0)