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

Context Sub Menu Does not function after first instantiation #1205

Open
davidwoolf opened this issue May 17, 2024 · 6 comments
Open

Context Sub Menu Does not function after first instantiation #1205

davidwoolf opened this issue May 17, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@davidwoolf
Copy link
Contributor

davidwoolf commented May 17, 2024

Describe the bug

When using sub menus in a context, the first initialization of the context menu allows you to hover over the sub trigger and open the menu. However, closing the context menu and reopening it breaks the sub menu functionality.

Additionally, arrow navigation is broken for the same flow.

This was tested in both Webkit and Chromium.

Reproduction

Check your own demo: https://melt-ui.com/docs/builders/context-menu

Logs

No logs are outputted for this issue.

System Info

System:
    OS: macOS 14.4.1
    CPU: (14) arm64 Apple M3 Max
    Memory: 84.05 MB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.1 - /usr/local/bin/node
    npm: 10.2.4 - /usr/local/bin/npm
    pnpm: 9.0.6 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 124.0.6367.209
    Safari: 17.4.1

Severity

blocking all usage of Melt UI

@davidwoolf davidwoolf added the bug Something isn't working label May 17, 2024
@davidwoolf
Copy link
Contributor Author

Note that this is a huge bug blocking usage of the context menu, which is an important feature for something I am working on.

@TGlide
Copy link
Member

TGlide commented May 17, 2024

Thanks for raising the issue! For a workaround, use forceVisible: true, and couple them with #if blocks.

@davidwoolf
Copy link
Contributor Author

davidwoolf commented May 17, 2024

@TGlide thanks for the tip! I tried that and unfortunately it seems to break it completely. The overall context menu works fine with that pattern, but I can't open the sub menu at all anymore.

I realize I may be doing this wrong, so let me provide some code:

<script>
  const {
    states: { open },
    elements: { subMenu, subTrigger },
  } = createSubmenu({ forceVisible: true });
</script>

<div {...$subTrigger} use:subTrigger>
  Trigger
</div>

{#if $open}
  <div {...$subMenu} use:subMenu>
     <slot />
  </div>
{/if}

@TGlide
Copy link
Member

TGlide commented May 17, 2024

Try only setting the root context menu with forceVisbible

@davidwoolf
Copy link
Contributor Author

davidwoolf commented May 17, 2024

Ok I figured it out and it works now!

Yes agreed to applying forceVisbible on the root context menu. Additionally, createSubmenu returns subOpen not open:

const {
    states: { subOpen },
    elements: { subMenu, subTrigger },
  } = createSubmenu(args);

@pierre-H
Copy link

pierre-H commented Jun 6, 2024

With Svelte 5, I have the same problem, event with forceVisible: true, and the {#if $subOpen} block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants