Skip to content

Commit

Permalink
Fix Auto hide without hook (#9780)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhimanyurajeesh authored Jan 6, 2025
1 parent ef4d63b commit c77a633
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
9 changes: 7 additions & 2 deletions src/components/ui/sidebar/facility-switcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function FacilitySwitcher({
facilities: UserFacilityModel[];
selectedFacility: UserFacilityModel | null;
}) {
const { isMobile } = useSidebar();
const { isMobile, setOpenMobile } = useSidebar();

return (
<SidebarMenu>
Expand Down Expand Up @@ -64,7 +64,12 @@ export function FacilitySwitcher({
{facilities.map((facility, index) => (
<DropdownMenuItem
key={index}
onClick={() => navigate(`/facility/${facility.id}`)}
onClick={() => {
navigate(`/facility/${facility.id}`);
if (isMobile) {
setOpenMobile(false);
}
}}
className="gap-2 p-2"
>
<div className="flex size-6 items-center justify-center rounded-sm border">
Expand Down
9 changes: 7 additions & 2 deletions src/components/ui/sidebar/nav-user.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -94,7 +94,12 @@ export function FacilityNavUser() {
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuItem
onClick={() => navigate(`/users/${user.username}`)}
onClick={() => {
navigate(`/users/${user.username}`);
if (isMobile) {
setOpenMobile(false);
}
}}
>
<BadgeCheck />
{t("profile")}
Expand Down
9 changes: 7 additions & 2 deletions src/components/ui/sidebar/organization-switcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function OrganizationSwitcher({
organizations,
selectedOrganization,
}: Props) {
const { isMobile } = useSidebar();
const { isMobile, setOpenMobile } = useSidebar();

return (
<DropdownMenu>
Expand Down Expand Up @@ -69,7 +69,12 @@ export function OrganizationSwitcher({
{organizations.map((org) => (
<DropdownMenuItem
key={org.id}
onClick={() => navigate(`/organization/${org.id}`)}
onClick={() => {
navigate(`/organization/${org.id}`);
if (isMobile) {
setOpenMobile(false);
}
}}
>
{org.name}
</DropdownMenuItem>
Expand Down

0 comments on commit c77a633

Please sign in to comment.