diff --git a/app/components/layout/ChatSidebar.module.css b/app/components/layout/ChatSidebar.module.css index 5007805ec..64fe34c95 100644 --- a/app/components/layout/ChatSidebar.module.css +++ b/app/components/layout/ChatSidebar.module.css @@ -2,7 +2,7 @@ display: flex; flex-direction: column; height: 100%; - max-height: var(--visual-viewport-height); + max-height: var(--visual-viewport-height, 100dvh); overflow: hidden; } diff --git a/app/components/layout/index.tsx b/app/components/layout/index.tsx index e340bdda5..0179dec2a 100644 --- a/app/components/layout/index.tsx +++ b/app/components/layout/index.tsx @@ -26,6 +26,8 @@ import { useChatContext } from "~/features/chat/useChatContext"; import { FriendMenu } from "~/features/friends/components/FriendMenu"; import { useDateTimeFormat } from "~/hooks/intl/useDateTimeFormat"; import { useHydrated } from "~/hooks/useHydrated"; +import { useLayoutSize } from "~/hooks/useMainContentWidth"; +import { useVisualViewportHeight } from "~/hooks/useVisualViewportHeight"; import type { RootLoaderData } from "~/root"; import type { Breadcrumb, SendouRouteHandle } from "~/utils/remix.server"; import { @@ -213,9 +215,16 @@ export function Layout({ const [sideNavModalOpen, setSideNavModalOpen] = React.useState(false); const [chatSidebarModalOpen, setChatSidebarModalOpen] = React.useState(false); + const layoutSize = useLayoutSize(); + useVisualViewportHeight(); const chatSidebarOpen = chatContext?.chatOpen ?? false; const setChatSidebarOpen = chatContext?.setChatOpen ?? (() => {}); + const setChatSidebarModalOpenAndSync = (open: boolean) => { + setChatSidebarModalOpen(open); + setChatSidebarOpen(open); + }; + const { t } = useTranslation(["front", "common"]); const { formatRelativeDate } = useRelativeDayFormat(); const isHydrated = useHydrated(); @@ -393,7 +402,7 @@ export function Layout({ className={styles.chatSidebarModalOverlay} isDismissable isOpen={chatSidebarModalOpen} - onOpenChange={setChatSidebarModalOpen} + onOpenChange={setChatSidebarModalOpenAndSync} > setChatSidebarModalOpen((prev) => !prev) + ? () => setChatSidebarModalOpenAndSync(!chatSidebarModalOpen) : undefined } chatUnreadCount={chatContext?.totalUnreadCount} @@ -440,7 +449,7 @@ export function Layout({ {children}