diff --git a/apps/storefront/src/components/header/mobile-search.tsx b/apps/storefront/src/components/header/mobile-search.tsx index 829c082..c5eae07 100644 --- a/apps/storefront/src/components/header/mobile-search.tsx +++ b/apps/storefront/src/components/header/mobile-search.tsx @@ -1,7 +1,7 @@ "use client"; import { Search } from "lucide-react"; -import { useParams, usePathname } from "next/navigation"; +import { usePathname } from "next/navigation"; import { useTranslations } from "next-intl"; import { useEffect, useState } from "react"; @@ -14,12 +14,11 @@ export const MobileSearch = () => { const t = useTranslations("search"); const pathname = usePathname(); - const params = useParams(); const [isOpen, setIsOpen] = useState(false); useEffect(() => { setIsOpen(false); - }, [pathname, params]); + }, [pathname]); return ( <> @@ -38,7 +37,7 @@ export const MobileSearch = () => { aria-label={t("search-label")} modal={true} > - + diff --git a/apps/storefront/src/components/header/mobile-side-menu.tsx b/apps/storefront/src/components/header/mobile-side-menu.tsx index 816dcae..9201d64 100644 --- a/apps/storefront/src/components/header/mobile-side-menu.tsx +++ b/apps/storefront/src/components/header/mobile-side-menu.tsx @@ -13,6 +13,7 @@ import { Sheet, SheetContent } from "@nimara/ui/components/sheet"; import { MobileNavigation } from "@/components/mobile-navigation"; import { paths } from "@/lib/paths"; +import { cn } from "@/lib/utils"; import { useCurrentRegion } from "@/regions/client"; import { LocaleSwitch } from "../locale-switch"; @@ -57,7 +58,14 @@ export const MobileSideMenu = ({
-
+
diff --git a/apps/storefront/src/components/header/search-form.tsx b/apps/storefront/src/components/header/search-form.tsx index 4cc603d..be41fd9 100644 --- a/apps/storefront/src/components/header/search-form.tsx +++ b/apps/storefront/src/components/header/search-form.tsx @@ -127,6 +127,14 @@ export const SearchForm = () => { } }; + const handleSearchIconClick = () => { + if (isNoOptionHighlighted || isLastOptionHighlighted) { + router.push(paths.search.asPath({ query: { q: inputValue } })); + + return; + } + }; + useClickAnyWhere(() => setSearchState((prevState) => ({ ...prevState, showOptions: false })), ); @@ -173,7 +181,8 @@ export const SearchForm = () => { size="icon" type="submit" variant="outline" - onClick={() => resetSearchState()} + className="cursor-pointer" + onClick={handleSearchIconClick} > {isLoading ? ( diff --git a/packages/ui/src/components/sheet.tsx b/packages/ui/src/components/sheet.tsx index 7a31ab7..7166db9 100644 --- a/packages/ui/src/components/sheet.tsx +++ b/packages/ui/src/components/sheet.tsx @@ -54,12 +54,14 @@ const sheetVariants = cva( interface SheetContentProps extends React.ComponentPropsWithoutRef, - VariantProps {} + VariantProps { + closeClassName?: string; +} const SheetContent = React.forwardRef< React.ElementRef, SheetContentProps ->(({ side = "right", className, children, ...props }, ref) => ( +>(({ side = "right", className, closeClassName, children, ...props }, ref) => ( {children} - + Close