diff --git a/src/components/left/main/ChatFolders.tsx b/src/components/left/main/ChatFolders.tsx index b65a1c9a3..68969a284 100644 --- a/src/components/left/main/ChatFolders.tsx +++ b/src/components/left/main/ChatFolders.tsx @@ -14,6 +14,7 @@ import useShowTransition from '../../../hooks/useShowTransition'; import buildClassName from '../../../util/buildClassName'; import useThrottledMemo from '../../../hooks/useThrottledMemo'; import useLang from '../../../hooks/useLang'; +import captureEscKeyListener from '../../../util/captureEscKeyListener'; import Transition from '../../ui/Transition'; import TabList from '../../ui/TabList'; @@ -122,6 +123,14 @@ const ChatFolders: FC = ({ }); }, [activeTab, folderTabs]); + const isNotInAllTabRef = useRef(); + isNotInAllTabRef.current = activeTab !== 0; + useEffect(() => captureEscKeyListener(() => { + if (isNotInAllTabRef.current) { + setActiveTab(0); + } + }), []); + const { shouldRender: shouldRenderPlaceholder, transitionClassNames, } = useShowTransition(!orderedFolderIds, undefined, true);