Skip to content

Commit

Permalink
feat(combobox): Add render action to combobox (#2297)
Browse files Browse the repository at this point in the history
  • Loading branch information
shaharzil authored Aug 8, 2024
1 parent d786e92 commit a6d4adb
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/core/src/components/Combobox/Combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {
COMBOBOX_LISTBOX_ID
} from "./components/ComboboxConstants";
import styles from "./Combobox.module.scss";
import IconButton from "../IconButton/IconButton";
import MenuButton from "../MenuButton/MenuButton";

export interface ComboboxProps extends VibeComponentProps {
className?: string;
Expand Down Expand Up @@ -115,6 +117,14 @@ export interface ComboboxProps extends VibeComponentProps {
searchInputAriaLabel?: string;
debounceRate?: number;
searchInputRef?: React.RefObject<HTMLInputElement>;
/**
* Render additional action within the right section of search component.
*/
renderAction?: React.ReactElement<typeof IconButton | typeof MenuButton>;
/**
* If true, hides the additional action when the user types in the search input.
*/
hideRenderActionOnInput?: boolean;
}

const Combobox: React.FC<ComboboxProps> & {
Expand Down Expand Up @@ -160,7 +170,9 @@ const Combobox: React.FC<ComboboxProps> & {
searchInputAriaLabel = "Search for content",
"data-testid": dataTestId,
debounceRate,
searchInputRef
searchInputRef,
renderAction: RenderAction,
hideRenderActionOnInput
},
ref
) => {
Expand Down Expand Up @@ -321,6 +333,8 @@ const Combobox: React.FC<ComboboxProps> & {
ariaHasPopup="listbox"
searchResultsContainerId={id ? `${id}-listbox` : COMBOBOX_LISTBOX_ID}
debounceRate={debounceRate}
renderAction={RenderAction}
hideRenderActionOnInput={hideRenderActionOnInput}
/>
{stickyCategories && <StickyCategoryHeader label={activeCategoryLabel} />}
<ComboboxItems
Expand Down

0 comments on commit a6d4adb

Please sign in to comment.