From 0c0b51916747eb120944fc206ae4457707654d40 Mon Sep 17 00:00:00 2001 From: Sophie Turner Date: Mon, 23 Sep 2024 13:41:14 +0500 Subject: [PATCH 1/2] fix(sid-bar): search text clears after click colllapsed button --- src/components/App/SideBar/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/App/SideBar/index.tsx b/src/components/App/SideBar/index.tsx index 5c756ad9a..6faa5ecb0 100644 --- a/src/components/App/SideBar/index.tsx +++ b/src/components/App/SideBar/index.tsx @@ -20,7 +20,7 @@ type ContentProp = { // eslint-disable-next-line react/display-name const Content = forwardRef(({ subViewOpen }, ref) => { - const { setSidebarOpen } = useAppStore((s) => s) + const { setSidebarOpen, currentSearch: searchTerm, setSearchFormValue } = useAppStore((s) => s) const hasAiChats = useHasAiChats() @@ -32,6 +32,7 @@ const Content = forwardRef(({ subViewOpen }, ref) = { setSidebarOpen(false) + setSearchFormValue(searchTerm || '') }} > From a54b039deb9137c61914e0fc59f8f67c217acbcf Mon Sep 17 00:00:00 2001 From: Sophie Turner Date: Fri, 18 Oct 2024 00:40:16 +0500 Subject: [PATCH 2/2] fix(sid-bar): search text clears after click colllapsed button --- src/components/App/SideBar/__tests__/index.tsx | 6 ++++-- src/components/App/SideBar/index.tsx | 5 ++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/App/SideBar/__tests__/index.tsx b/src/components/App/SideBar/__tests__/index.tsx index a4ba3b318..ae2c6ff15 100644 --- a/src/components/App/SideBar/__tests__/index.tsx +++ b/src/components/App/SideBar/__tests__/index.tsx @@ -3,8 +3,8 @@ import { ThemeProvider } from '@mui/material' import '@testing-library/jest-dom' import { fireEvent, render, screen, waitFor } from '@testing-library/react' import React from 'react' -import { ThemeProvider as StyleThemeProvider } from 'styled-components' import { MemoryRouter } from 'react-router-dom' +import { ThemeProvider as StyleThemeProvider } from 'styled-components' import { SideBar } from '..' import { api } from '../../../../network/api' import { AppStore, useAppStore } from '../../../../stores/useAppStore' @@ -101,7 +101,9 @@ describe('Test SideBar', () => { , ) - expect(container.querySelector('#sidebar-wrapper')).not.toBeInTheDocument() + waitFor(() => { + expect(container.querySelector('#sidebar-wrapper')).not.toBeInTheDocument() + }) }) it('Verify that the sidebar is visible when sidebarIsOpen is true.', () => { diff --git a/src/components/App/SideBar/index.tsx b/src/components/App/SideBar/index.tsx index 6faa5ecb0..fa207294d 100644 --- a/src/components/App/SideBar/index.tsx +++ b/src/components/App/SideBar/index.tsx @@ -20,7 +20,7 @@ type ContentProp = { // eslint-disable-next-line react/display-name const Content = forwardRef(({ subViewOpen }, ref) => { - const { setSidebarOpen, currentSearch: searchTerm, setSearchFormValue } = useAppStore((s) => s) + const { setSidebarOpen } = useAppStore((s) => s) const hasAiChats = useHasAiChats() @@ -32,7 +32,6 @@ const Content = forwardRef(({ subViewOpen }, ref) = { setSidebarOpen(false) - setSearchFormValue(searchTerm || '') }} > @@ -67,7 +66,7 @@ export const SideBar = () => { return ( <> - +