Skip to content

Commit

Permalink
fix(sid-bar): search text clears after click colllapsed button
Browse files Browse the repository at this point in the history
  • Loading branch information
sophieturner0 committed Oct 17, 2024
1 parent 0cd7594 commit a54b039
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/components/App/SideBar/__tests__/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -101,7 +101,9 @@ describe('Test SideBar', () => {
</MemoryRouter>,
)

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.', () => {
Expand Down
5 changes: 2 additions & 3 deletions src/components/App/SideBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type ContentProp = {

// eslint-disable-next-line react/display-name
const Content = forwardRef<HTMLDivElement, ContentProp>(({ subViewOpen }, ref) => {
const { setSidebarOpen, currentSearch: searchTerm, setSearchFormValue } = useAppStore((s) => s)
const { setSidebarOpen } = useAppStore((s) => s)

const hasAiChats = useHasAiChats()

Expand All @@ -32,7 +32,6 @@ const Content = forwardRef<HTMLDivElement, ContentProp>(({ subViewOpen }, ref) =
<CollapseButton
onClick={() => {
setSidebarOpen(false)
setSearchFormValue(searchTerm || '')
}}
>
<ChevronLeftIcon />
Expand Down Expand Up @@ -67,7 +66,7 @@ export const SideBar = () => {

return (
<>
<Slide direction="right" in={sidebarIsOpen} mountOnEnter unmountOnExit>
<Slide direction="right" in={sidebarIsOpen}>
<Content subViewOpen={subViewIsOpen} />
</Slide>
<SideBarSubView open={subViewIsOpen} />
Expand Down

0 comments on commit a54b039

Please sign in to comment.