Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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/nine-glasses-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': minor
---

Added an optional `fiterLabel` prop to `ActionList` to allow for a custom placeholder
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ export const WithFiltering = {
items={Array.from({length: 8}).map((_, index) => ({
content: `Item #${index + 1}`,
}))}
filterLabel="Search items"
/>
</div>
);
Expand Down
17 changes: 13 additions & 4 deletions polaris-react/src/components/ActionList/ActionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export interface ActionListProps {
actionRole?: 'menuitem' | string;
/** Allow users to filter items in the list. Will only show if more than 8 items in the list. The item content of every items must be a string for this to work */
allowFiltering?: boolean;
/** Filter label used as a placeholder in the search field */
filterLabel?: string;
/** Callback when any item is clicked or keypressed */
onActionAnyItem?: ActionListItemDescriptor['onAction'];
}
Expand All @@ -40,6 +42,7 @@ export function ActionList({
actionRole,
allowFiltering,
onActionAnyItem,
filterLabel,
}: ActionListProps) {
const i18n = useI18n();
const filterActions = useContext(FilterActionsContext);
Expand Down Expand Up @@ -153,10 +156,16 @@ export function ActionList({
<TextField
clearButton
labelHidden
label={i18n.translate('Polaris.ActionList.SearchField.placeholder')}
placeholder={i18n.translate(
'Polaris.ActionList.SearchField.placeholder',
)}
label={
filterLabel
? filterLabel
: i18n.translate('Polaris.ActionList.SearchField.placeholder')
}
placeholder={
filterLabel
? filterLabel
: i18n.translate('Polaris.ActionList.SearchField.placeholder')
}
autoComplete="off"
value={searchText}
onChange={(value) => setSearchText(value)}
Expand Down