Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose textInputProps from SelectPanel #1311

Merged
merged 5 commits into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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/brown-glasses-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/components': patch
---

Expose 'textInputProps' from the 'SelectPanel'
18 changes: 11 additions & 7 deletions src/SelectPanel/SelectPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ const focusZoneSettings: Partial<FocusZoneHookSettings> = {
disabled: true
}

const textInputProps: Partial<TextInputProps> = {
mx: 2,
my: 2,
contrast: true
}

export function SelectPanel({
open,
onOpenChange,
Expand All @@ -62,6 +56,7 @@ export function SelectPanel({
filterValue: externalFilterValue,
onFilterChange: externalOnFilterChange,
items,
textInputProps,
overlayProps,
...listProps
}: SelectPanelProps): JSX.Element {
Expand Down Expand Up @@ -132,6 +127,15 @@ export function SelectPanel({
initialFocusRef: inputRef
}

const extendedTextInputProps: Partial<TextInputProps> = useMemo(() => {
return {
mx: 2,
my: 2,
contrast: true,
...textInputProps
}
}, [textInputProps])
lukewar marked this conversation as resolved.
Show resolved Hide resolved

return (
<AnchoredOverlay
renderAnchor={renderMenuAnchor}
Expand All @@ -150,7 +154,7 @@ export function SelectPanel({
role="listbox"
items={itemsToRender}
selectionVariant={isMultiSelectVariant(selected) ? 'multiple' : 'single'}
textInputProps={textInputProps}
textInputProps={extendedTextInputProps}
inputRef={inputRef}
/>
</Flex>
Expand Down