Skip to content

Commit

Permalink
Merge pull request #8692 from dharmik/issues/dharmik-8329-fabmenu-pop…
Browse files Browse the repository at this point in the history
…up-issue-resolve

fix: 8329: Resolve fabmenu open multiple time
  • Loading branch information
tgolen authored Apr 25, 2022
2 parents be7fd88 + 1978bf7 commit 16b130b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions src/libs/actions/WelcomeActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ Onyx.connect({
*
* @param {Object} params
* @param {Object} params.routes
* @param {Function} params.toggleCreateMenu
* @param {Function} params.hideCreateMenu
*/
function show({routes, toggleCreateMenu}) {
function show({routes, hideCreateMenu}) {
// NOTE: This setTimeout is required due to a bug in react-navigation where modals do not display properly in a drawerContent
// This is a short-term workaround, see this issue for updates on a long-term solution: https://github.com/Expensify/App/issues/5296
setTimeout(() => {
Expand All @@ -72,10 +72,10 @@ function show({routes, toggleCreateMenu}) {
const exitingToWorkspaceRoute = lodashGet(loginWithShortLivedTokenRoute, 'params.exitTo', '') === 'workspace/new';
const isDisplayingWorkspaceRoute = topRouteName.toLowerCase().includes('workspace') || exitingToWorkspaceRoute;

// It's also possible that we already have a workspace policy. In either case we will not toggle the menu but do still want to set the NVP in this case
// It's also possible that we already have a workspace policy. In either case we will not hide the menu but do still want to set the NVP in this case
// since the user does not need to create a workspace.
if (!Policy.isAdminOfFreePolicy(allPolicies) && !isDisplayingWorkspaceRoute) {
toggleCreateMenu();
hideCreateMenu();
}
}, 1500);
}
Expand Down
30 changes: 15 additions & 15 deletions src/pages/home/sidebar/SidebarScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ class SidebarScreen extends Component {
constructor(props) {
super(props);

this.onCreateMenuItemSelected = this.onCreateMenuItemSelected.bind(this);
this.toggleCreateMenu = this.toggleCreateMenu.bind(this);
this.hideCreateMenu = this.hideCreateMenu.bind(this);
this.startTimer = this.startTimer.bind(this);
this.navigateToSettings = this.navigateToSettings.bind(this);
this.showCreateMenu = this.showCreateMenu.bind(this);

this.state = {
isCreateMenuActive: false,
Expand All @@ -58,14 +58,16 @@ class SidebarScreen extends Component {
Timing.start(CONST.TIMING.SIDEBAR_LOADED, true);

const routes = lodashGet(this.props.navigation.getState(), 'routes', []);
WelcomeAction.show({routes, toggleCreateMenu: this.toggleCreateMenu});
WelcomeAction.show({routes, hideCreateMenu: this.hideCreateMenu});
}

/**
* Method called when a Create Menu item is selected.
* Method called when we click the floating action button
*/
onCreateMenuItemSelected() {
this.toggleCreateMenu();
showCreateMenu() {
this.setState({
isCreateMenuActive: true,
});
}

/**
Expand All @@ -76,16 +78,14 @@ class SidebarScreen extends Component {
}

/**
* Method called when we click the floating action button
* will trigger the animation
* Method called either when:
* Pressing the floating action button to open the CreateMenu modal
* Selecting an item on CreateMenu or closing it by clicking outside of the modal component
*/
toggleCreateMenu() {
this.setState(state => ({
isCreateMenuActive: !state.isCreateMenuActive,
}));
hideCreateMenu() {
this.setState({
isCreateMenuActive: false,
});
}

/**
Expand Down Expand Up @@ -117,14 +117,14 @@ class SidebarScreen extends Component {
accessibilityLabel={this.props.translate('sidebarScreen.fabNewChat')}
accessibilityRole="button"
isActive={this.state.isCreateMenuActive}
onPress={this.toggleCreateMenu}
onPress={this.showCreateMenu}
/>
</View>
<PopoverMenu
onClose={this.toggleCreateMenu}
onClose={this.hideCreateMenu}
isVisible={this.state.isCreateMenuActive}
anchorPosition={styles.createMenuPositionSidebar}
onItemSelected={this.onCreateMenuItemSelected}
onItemSelected={this.hideCreateMenu}
fromSidebarMediumScreen={!this.props.isSmallScreenWidth}
menuItems={[
{
Expand Down

0 comments on commit 16b130b

Please sign in to comment.