diff options
author | Ollie H <renahlee@outlook.com> | 2023-05-17 07:46:10 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-17 09:46:10 -0500 |
commit | 656baa723913951e2a2961f00f0e5219660d0885 (patch) | |
tree | 60279f7792324959ddea143308f26dd98ec7d7c3 /src/view/shell/index.web.tsx | |
parent | 09bb2f52084724e9e5b000a7c59a78559c9b743e (diff) | |
download | voidsky-656baa723913951e2a2961f00f0e5219660d0885.tar.zst |
Close active elements on state change (#677)
Diffstat (limited to 'src/view/shell/index.web.tsx')
-rw-r--r-- | src/view/shell/index.web.tsx | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/view/shell/index.web.tsx b/src/view/shell/index.web.tsx index 349376436..68ce370ed 100644 --- a/src/view/shell/index.web.tsx +++ b/src/view/shell/index.web.tsx @@ -1,4 +1,4 @@ -import React from 'react' +import React, {useEffect} from 'react' import {observer} from 'mobx-react-lite' import {View, StyleSheet, TouchableOpacity} from 'react-native' import {useStores} from 'state/index' @@ -14,11 +14,21 @@ import {RoutesContainer, FlatNavigator} from '../../Navigation' import {DrawerContent} from './Drawer' import {useWebMediaQueries} from '../../lib/hooks/useWebMediaQueries' import {BottomBarWeb} from './bottom-bar/BottomBarWeb' +import {useNavigation} from '@react-navigation/native' +import {NavigationProp} from 'lib/routes/types' const ShellInner = observer(() => { const store = useStores() const {isDesktop} = useWebMediaQueries() + const navigator = useNavigation<NavigationProp>() + + useEffect(() => { + navigator.addListener('state', () => { + store.shell.closeAnyActiveElement() + }) + }, [navigator, store.shell]) + return ( <> <View style={s.hContentRegion}> |