Skip to content

Commit

Permalink
Add closeOnSelect prop
Browse files Browse the repository at this point in the history
  • Loading branch information
sandervspl committed Jul 27, 2024
1 parent ed4af22 commit 19aa210
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions apps/website/src/components/common/item-search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Props = {
className?: string;
onBlur?: () => void;
searchItem?: (props: { item: SearchItem }) => React.ReactNode;
closeOnSelect?: boolean;
};

export type SearchItem = {
Expand Down Expand Up @@ -57,8 +58,7 @@ export const ItemSearch = React.forwardRef((props: Props, ref) => {
items={searchQuery.data ?? []}
selectionBehavior="clear"
className={props.className}
closeOnSelect={!!props.searchItem}
open={true}
closeOnSelect={props.closeOnSelect ?? false}
onValueChange={(details) => {
// If we have a custom item component we don't want to use the default action
if (!props.searchItem) {
Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/components/modules/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const Navbar = () => {
<Image src={IconSvg} alt="logo" className="size-6" />
<div className="hidden sm:block text-lg font-bold ">auctionoton</div>
</Link>
<ItemSearch />
<ItemSearch closeOnSelect />
</div>

<div className="ml-auto self-center gap-2 hidden md:flex">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export const DashboardSection = ({ section }: Props) => {
// Component needs to always be mounted or else the results don't render
className={cn({ 'sr-only': !isSearching, 'w-full': isSearching })}
searchItem={(props) => <SearchItemComponent {...props} section={section} />}
closeOnSelect
/>
{!isSearching && (
<Button
Expand Down

0 comments on commit 19aa210

Please sign in to comment.