@@ -9,7 +9,7 @@ import React from "react";
9
9
import { Link } from "react-router-dom" ;
10
10
import { useParams } from "react-router" ;
11
11
import cn from "classnames" ;
12
- import { makeStyles , Theme } from "@material-ui/core" ;
12
+ import { makeStyles , Theme , useMediaQuery } from "@material-ui/core" ;
13
13
import Drawer from '@material-ui/core/Drawer' ;
14
14
import List from "@material-ui/core/List" ;
15
15
import Divider from "@material-ui/core/Divider" ;
@@ -18,6 +18,7 @@ import Box from "@mui/material/Box";
18
18
import { Spinner } from "@postgres.ai/shared/components/Spinner" ;
19
19
import { HeaderButtons , HeaderButtonsProps } from "../HeaderButtons/HeaderButtons" ;
20
20
import { BotMessage } from "../../../types/api/entities/bot" ;
21
+ import { theme } from "@postgres.ai/shared/styles/theme" ;
21
22
22
23
23
24
const useStyles = makeStyles < Theme , ChatsListProps > ( ( theme ) => ( {
@@ -111,7 +112,7 @@ export const ChatsList = (props: ChatsListProps) => {
111
112
} = props ;
112
113
const classes = useStyles ( props ) ;
113
114
const params = useParams < { org ?: string , threadId ?: string } > ( ) ;
114
-
115
+ const matches = useMediaQuery ( theme . breakpoints . down ( 'sm' ) ) ;
115
116
const linkBuilder = ( msgId : string ) => {
116
117
if ( params . org ) {
117
118
return `/${ params . org } /bot/${ msgId } `
@@ -126,6 +127,12 @@ export const ChatsList = (props: ChatsListProps) => {
126
127
}
127
128
}
128
129
130
+ const handleCloseOnClickOutside = ( ) => {
131
+ if ( matches ) {
132
+ onClose ( )
133
+ }
134
+ }
135
+
129
136
const loader = (
130
137
< Box className = { classes . loader } >
131
138
< Spinner />
@@ -172,11 +179,12 @@ export const ChatsList = (props: ChatsListProps) => {
172
179
173
180
return (
174
181
< Drawer
175
- variant = { 'persistent' }
182
+ variant = { matches ? 'temporary' : 'persistent' }
176
183
anchor = "right"
177
184
BackdropProps = { { invisible : true } }
178
185
elevation = { 1 }
179
186
open = { isOpen }
187
+ onClose = { handleCloseOnClickOutside }
180
188
classes = { {
181
189
paper : classes . drawerPaper
182
190
} }
0 commit comments