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

[Bug Report][3.1.11] VMenu - Menu closes when nested menu closes #17004

Closed
joel-wenzel opened this issue Mar 25, 2023 · 10 comments · Fixed by #19239
Closed

[Bug Report][3.1.11] VMenu - Menu closes when nested menu closes #17004

joel-wenzel opened this issue Mar 25, 2023 · 10 comments · Fixed by #19239
Assignees
Labels
C: VMenu VMenu T: bug Functionality that does not work as intended/expected
Milestone

Comments

@joel-wenzel
Copy link
Contributor

Environment

Vuetify Version: 3.1.11
Last working version: 2.6.14
Vue Version: 3.2.47
Browsers: Chrome 111.0.0.0
OS: Windows 10

Steps to reproduce

  • Click the button to open the menu
  • Click the inner button to open the nested menu
  • Click back into the first menu (it should remain open but closes).

Expected Behavior

Only the inner menu should close when clicking back into the first menu

Actual Behavior

Both menus close

Reproduction Link

https://play.vuetifyjs.com/#...

Other comments

Works in vuetify 2: https://codepen.io/joel-wenzel/pen/gOdqMgQ
I tried attaching the inner menu to the parent menu just to see if that changed anything and it doesnt.

@fahmifitu
Copy link
Contributor

HEy, I have the same issue. Have you found any workarounds?

@meghanmae
Copy link

We are also experiencing this issue! Has there been any movement on this?

@joel-wenzel
Copy link
Contributor Author

@fahmifitu @mmwoodfo I havent found a work around, but I was able to fix it using https://www.npmjs.com/package/patch-package
Here is the diff in VMenu:

-      closeParents() {
+     closeParents(event) {
         setTimeout(() => {
           if (!openChildren.value) {
-            isActive.value = false;
-            parent?.closeParents();
+            if(event && !overlay.value.contentEl.contains(event.target)) {
+              isActive.value = false;
+              parent?.closeParents();
+            }
           }
         }, 40);

-    function onClickOutside() {
-      parent?.closeParents();
+    function onClickOutside(event) {
+      parent?.closeParents(event);
     }

I haven't submitted a PR for this myself because I feel its kind of a hacky solution, waiting to see what the vuetify team does.

@fahmifitu
Copy link
Contributor

fahmifitu commented Jun 29, 2023

@mmwoodfo @joel-wenzel I used a v-overlay as follows and made it function as a menu. it doesn't have this issue

<v-overlay
    v-bind="{
      openOnFocus: false,
      openOnClick: true,
      closeOnContentClick: false,
      closeDelay: 0,
      openDelay: 0,
      locationStrategy: 'connected',
      scrim: false,
      scrollStrategy: 'reposition',
      maxWidth: '280px',
      contentProps: { style: 'min-width: unset !important;' },
    }"
  >

@vicdotexe
Copy link

vicdotexe commented Jun 30, 2023

@fahmifitu

I used a v-overlay as follows and made it function as a menu. it doesn't have this issue

This is also what I ended up doing earlier today and works pretty well. contentProps: { style: 'min-width: unset !important;' }, was what I was missing though, so thank you!

@sametaylak
Copy link

sametaylak commented Aug 2, 2023

any updates on this? @KaelWD

@ghost
Copy link

ghost commented Oct 3, 2023

Any adjustment predictions?

@marilgt
Copy link

marilgt commented Oct 3, 2023

Have the same problem. Any updates?

@3dyuval
Copy link

3dyuval commented Dec 6, 2023

I've also tried to troubleshoot this untill I found this issue. demo

@yuwu9145
Copy link
Member

yuwu9145 commented Feb 16, 2024

@fahmifitu @mmwoodfo I havent found a work around, but I was able to fix it using https://www.npmjs.com/package/patch-package Here is the diff in VMenu:

-      closeParents() {
+     closeParents(event) {
         setTimeout(() => {
           if (!openChildren.value) {
-            isActive.value = false;
-            parent?.closeParents();
+            if(event && !overlay.value.contentEl.contains(event.target)) {
+              isActive.value = false;
+              parent?.closeParents();
+            }
           }
         }, 40);

-    function onClickOutside() {
-      parent?.closeParents();
+    function onClickOutside(event) {
+      parent?.closeParents(event);
     }

I haven't submitted a PR for this myself because I feel its kind of a hacky solution, waiting to see what the vuetify team does.

I have been trying to fix this issue for a pretty long time, I think your fix makes sense:

  • closeParents seem to be designed to close all upstream parent menus when mouse point is outside all menus
  • It makes sense to stop closing parent menus when clicking point is inside its immediate parent
  • variables inside closeParents function belong to parent lexical scope

I have tested all working good and it makes good sense @joel-wenzel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VMenu VMenu T: bug Functionality that does not work as intended/expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants