Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Menu returns after toggling off #111

Open
knownasilya opened this issue Dec 25, 2020 · 1 comment
Open

Menu returns after toggling off #111

knownasilya opened this issue Dec 25, 2020 · 1 comment

Comments

@knownasilya
Copy link

knownasilya commented Dec 25, 2020

mm

On opening the modal I toggle the right menu. The above happens when I cancel the modal. Looks like two menus render and they are both open. This only seems to happen when using (fn mmw.actions.toggle 'right')

Code

<MobileMenuWrapper @embed={{true}} as |mmw|>
  <mmw.MobileMenu @type='right'>
    <button
      type='button'
      role='menuitem'
      {{on
        'click'
        (pipe (fn this.send 'RENAME') (fn mmw.actions.toggle 'right'))
      }}
    >
      Update Title
    </button>
  </mmw.MobileMenu>

  <mmw.Content class='bg-gray-100 flex flex-col flex-1'>
    {{yield}}
    <mmw.Toggle @target='right'>
      <Button
        class='flex items-center py-2 px-4 group'
        id='post-menu'
        aria-label='Post Settings'
        aria-haspopup='true'
        @appearance='outlined'
      >
        <Icon
          @icon='ellipsis-v'
          class='text-gray-700 group-hover:text-white'
        />
      </Button>
    </mmw.Toggle>

    other content here
  </mmw.Content>
</MobileMenuWrapper>

<Modal
  @isOpen={{this.isRenameModalOpen}}
  @onClose={{fn this.send 'CANCEL'}} as |m|
>
 ....
</Modal>
@nickschot
Copy link
Owner

Sounds like this might be a bug related to this code:

if (targetMenu) {
this.close();
if (this.activeMenu !== targetMenu) {
this.open(targetMenu);
}
}

Could you try & modify those lines into:

    if (targetMenu) {
      let activeIsTarget = this.activeMenu === targetMenu;
      this.close();
      if (!activeIsTarget) {
        this.open(targetMenu);
      }
    }

and see if that fixes it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants