From c77a63338d00753dec39cf49a2ef7cd4a8d5c988 Mon Sep 17 00:00:00 2001 From: Abhimanyu Rajeesh <63541653+abhimanyurajeesh@users.noreply.github.com> Date: Mon, 6 Jan 2025 18:20:35 +0530 Subject: [PATCH] Fix Auto hide without hook (#9780) --- src/components/ui/sidebar/facility-switcher.tsx | 9 +++++++-- src/components/ui/sidebar/nav-user.tsx | 9 +++++++-- src/components/ui/sidebar/organization-switcher.tsx | 9 +++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/components/ui/sidebar/facility-switcher.tsx b/src/components/ui/sidebar/facility-switcher.tsx index cc63509381b..59715e4e02c 100644 --- a/src/components/ui/sidebar/facility-switcher.tsx +++ b/src/components/ui/sidebar/facility-switcher.tsx @@ -26,7 +26,7 @@ export function FacilitySwitcher({ facilities: UserFacilityModel[]; selectedFacility: UserFacilityModel | null; }) { - const { isMobile } = useSidebar(); + const { isMobile, setOpenMobile } = useSidebar(); return ( @@ -64,7 +64,12 @@ export function FacilitySwitcher({ {facilities.map((facility, index) => ( navigate(`/facility/${facility.id}`)} + onClick={() => { + navigate(`/facility/${facility.id}`); + if (isMobile) { + setOpenMobile(false); + } + }} className="gap-2 p-2" >
diff --git a/src/components/ui/sidebar/nav-user.tsx b/src/components/ui/sidebar/nav-user.tsx index 13ed450d4f3..56857862ad4 100644 --- a/src/components/ui/sidebar/nav-user.tsx +++ b/src/components/ui/sidebar/nav-user.tsx @@ -31,7 +31,7 @@ import { AppointmentPatient } from "@/pages/Patient/Utils"; export function FacilityNavUser() { const { t } = useTranslation(); const user = useAuthUser(); - const { isMobile, open } = useSidebar(); + const { isMobile, open, setOpenMobile } = useSidebar(); const { signOut } = useAuthContext(); return ( @@ -94,7 +94,12 @@ export function FacilityNavUser() { navigate(`/users/${user.username}`)} + onClick={() => { + navigate(`/users/${user.username}`); + if (isMobile) { + setOpenMobile(false); + } + }} > {t("profile")} diff --git a/src/components/ui/sidebar/organization-switcher.tsx b/src/components/ui/sidebar/organization-switcher.tsx index 675abd5e28c..d5af48af504 100644 --- a/src/components/ui/sidebar/organization-switcher.tsx +++ b/src/components/ui/sidebar/organization-switcher.tsx @@ -28,7 +28,7 @@ export function OrganizationSwitcher({ organizations, selectedOrganization, }: Props) { - const { isMobile } = useSidebar(); + const { isMobile, setOpenMobile } = useSidebar(); return ( @@ -69,7 +69,12 @@ export function OrganizationSwitcher({ {organizations.map((org) => ( navigate(`/organization/${org.id}`)} + onClick={() => { + navigate(`/organization/${org.id}`); + if (isMobile) { + setOpenMobile(false); + } + }} > {org.name}