From 776a60c363be2f196ac6951936a1dbed21886082 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Thu, 13 May 2021 12:57:12 +0300 Subject: [PATCH] Chat Folders: Support key to return to "All" tab --- src/components/left/main/ChatFolders.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) 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);