-
Notifications
You must be signed in to change notification settings - Fork 616
SelectPanel: Add filter input label and description #3312
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
Changes from all commits
1d68fee
c60e573
65e34a7
a546be0
f50ad4a
5df167a
f1a6afd
cf4c84e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@primer/react": patch | ||
--- | ||
|
||
SelectPanel: Add filter input label and description |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ import {TextInputProps} from '../TextInput' | |
import {useProvidedStateOrCreate} from '../hooks/useProvidedStateOrCreate' | ||
import {AnchoredOverlayWrapperAnchorProps} from '../AnchoredOverlay/AnchoredOverlay' | ||
import {useProvidedRefOrCreate} from '../hooks' | ||
import {SearchIcon} from '@primer/octicons-react' | ||
|
||
interface SelectPanelSingleSelection { | ||
selected: ItemInput | undefined | ||
|
@@ -27,6 +28,8 @@ interface SelectPanelBaseProps { | |
gesture: 'anchor-click' | 'anchor-key-press' | 'click-outside' | 'escape' | 'selection', | ||
) => void | ||
placeholder?: string | ||
// TODO: Make `inputLabel` required in next major version | ||
inputLabel?: string | ||
overlayProps?: Partial<OverlayProps> | ||
} | ||
|
||
|
@@ -53,6 +56,8 @@ export function SelectPanel({ | |
renderAnchor = props => <DropdownButton {...props} />, | ||
anchorRef: externalAnchorRef, | ||
placeholder, | ||
placeholderText = 'Filter items', | ||
inputLabel = placeholderText, | ||
selected, | ||
onSelectedChange, | ||
filterValue: externalFilterValue, | ||
|
@@ -141,9 +146,11 @@ export function SelectPanel({ | |
return { | ||
sx: {m: 2}, | ||
contrast: true, | ||
leadingVisual: SearchIcon, | ||
'aria-label': inputLabel, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd say it doesn't matter as much as they both will announce the same. I'd say one benefit that you could potentially gain with a visually hidden label and |
||
...textInputProps, | ||
} | ||
}, [textInputProps]) | ||
}, [inputLabel, textInputProps]) | ||
|
||
return ( | ||
<AnchoredOverlay | ||
|
@@ -159,6 +166,7 @@ export function SelectPanel({ | |
<FilteredActionList | ||
filterValue={filterValue} | ||
onFilterChange={onFilterChange} | ||
placeholderText={placeholderText} | ||
{...listProps} | ||
role="listbox" | ||
aria-multiselectable={isMultiSelectVariant(selected) ? 'true' : 'false'} | ||
|
Uh oh!
There was an error while loading. Please reload this page.