Skip to content

Ability to unset emptyStateText in Autocomplete.Menu #4002

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

Merged
7 changes: 7 additions & 0 deletions .changeset/nasty-dogs-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@primer/react": patch
---

Adds the ability to unset `emptyStateText` in Autocomplete.Menu. This results in no menu being rendered.

<!-- Changed components: Autocomplete -->
6 changes: 3 additions & 3 deletions src/Autocomplete/AutocompleteMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export type AutocompleteMenuInternalProps<T extends AutocompleteItemProps> = {
/**
* The text that appears in the menu when there are no options in the array passed to the `items` prop.
*/
emptyStateText?: React.ReactNode | false
emptyStateText?: React.ReactNode | false | null

/**
* A custom function used to filter the options in the array passed to the `items` prop.
Expand Down Expand Up @@ -363,9 +363,9 @@ function AutocompleteMenu<T extends AutocompleteItemProps>(props: AutocompleteMe
)
})}
</ActionList>
) : (
) : emptyStateText !== false && emptyStateText !== null ? (
<Box p={3}>{emptyStateText}</Box>
)}
) : null}
</div>
)}
</VisuallyHidden>
Expand Down