From 3d0e7830069c588e77961e5a53548496e050c0f6 Mon Sep 17 00:00:00 2001 From: Xiangxuan Liu <9570112+nauxliu@users.noreply.github.com> Date: Tue, 21 Mar 2023 23:46:20 +0800 Subject: [PATCH] Auto close sidebar when a conversation is selected/created on mobile (#47) --- pages/index.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pages/index.tsx b/pages/index.tsx index 5cb2424..64c2ab7 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -21,6 +21,13 @@ export default function Home() { const [messageError, setMessageError] = useState(false); const [modelError, setModelError] = useState(false); + // Close sidebar when a conversation is selected/created on mobile + useEffect(() => { + if (window.innerWidth < 640) { + setShowSidebar(false); + } + }, [selectedConversation]) + const handleSend = async (message: Message, isResend: boolean) => { if (selectedConversation) { let updatedConversation: Conversation;