Chat Folders: Support <Esc> key to return to "All" tab

This commit is contained in:
Alexander Zinchuk 2021-05-13 12:57:12 +03:00
parent ab448de3d4
commit 776a60c363

View File

@ -14,6 +14,7 @@ import useShowTransition from '../../../hooks/useShowTransition';
import buildClassName from '../../../util/buildClassName'; import buildClassName from '../../../util/buildClassName';
import useThrottledMemo from '../../../hooks/useThrottledMemo'; import useThrottledMemo from '../../../hooks/useThrottledMemo';
import useLang from '../../../hooks/useLang'; import useLang from '../../../hooks/useLang';
import captureEscKeyListener from '../../../util/captureEscKeyListener';
import Transition from '../../ui/Transition'; import Transition from '../../ui/Transition';
import TabList from '../../ui/TabList'; import TabList from '../../ui/TabList';
@ -122,6 +123,14 @@ const ChatFolders: FC<StateProps & DispatchProps> = ({
}); });
}, [activeTab, folderTabs]); }, [activeTab, folderTabs]);
const isNotInAllTabRef = useRef();
isNotInAllTabRef.current = activeTab !== 0;
useEffect(() => captureEscKeyListener(() => {
if (isNotInAllTabRef.current) {
setActiveTab(0);
}
}), []);
const { const {
shouldRender: shouldRenderPlaceholder, transitionClassNames, shouldRender: shouldRenderPlaceholder, transitionClassNames,
} = useShowTransition(!orderedFolderIds, undefined, true); } = useShowTransition(!orderedFolderIds, undefined, true);