Skip to content

Commit

Permalink
add logic to keep drawer closed
Browse files Browse the repository at this point in the history
  • Loading branch information
luacmartins committed Sep 29, 2022
1 parent 281bd48 commit 01638f8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/libs/Navigation/DeprecatedCustomActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,21 @@ function pushDrawerRoute(route) {

// Force drawer to close
// https://github.com/react-navigation/react-navigation/blob/94ab791cae5061455f036cd3f6bc7fa63167e7c7/packages/routers/src/DrawerRouter.tsx#L142
const hasDrawerhistory = _.find(state.history || [], h => h.type === 'drawer');
if (!hasDrawerhistory || currentState.type !== 'drawer') {
const drawerHistoryItem = _.find(state.history || [], h => h.type === 'drawer');
const isDrawerClosed = drawerHistoryItem && drawerHistoryItem.status === 'closed';
if (!drawerHistoryItem || currentState.type !== 'drawer') {
history.push({
type: 'drawer',

// If current state is not from drawer navigator then always use closed status to close the drawer
status: currentState.type !== 'drawer' || currentState.default === 'open' ? 'closed' : 'open',
});
} else if (isDrawerClosed) {
// Keep the drawer closed if it's already closed
history.push({
type: 'drawer',
status: 'closed',
});
}

return CommonActions.reset({
Expand Down

0 comments on commit 01638f8

Please sign in to comment.