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

Problem with menu closing after clicking on parent. #8

Open
AndreyKachanov opened this issue Jan 29, 2023 · 3 comments
Open

Problem with menu closing after clicking on parent. #8

AndreyKachanov opened this issue Jan 29, 2023 · 3 comments

Comments

@AndreyKachanov
Copy link

AndreyKachanov commented Jan 29, 2023

After clicking on an item, I need to close the menu. I can do this via the event @item-click. (set collapsed=true).
My parent menu items also contains href: '/...'. I use vueRouterEnabel.
And how do I make it so that when you click on the parent, you can:

  1. Use child menu items (i.e. expand the menu to view children) and be able to use the parent item as a link (href:'') to another page.
  2. It was possible to close the menu after clicking on the parent (meaning following the link href: '/...').
@amirkian007
Copy link
Owner

@AndreyKachanov
Hi, thanks for reporting the issue , I can't understand what you are trying to do, can you give me an clear example of the behavior you are looking for?
Is this the behavior you are looking for?:
1-click on a menu item
2-then push to a route
3-then open children container menu
2-then close the menu

@AndreyKachanov
Copy link
Author

Hi. Yes, but,

  1. in addition, I need that when clicking on the parent element, the menu also closes.
  2. by clicking on the parent, the route could also open.

Like in this video for example.
The parent has 2 functions: 1) it shows the child elements 2) it acts as a route to the page.
By clicking on both the parent and the children, the menu should close.
Can this be done with your plugin?

Kazam_screencast_00005.mp4

@amirkian007
Copy link
Owner

@AndreyKachanov
i see...
now the behavior is that when you click on a menu item it toggles the children items container, if you need an option to force close an children items container when clicking on parent or child element when router push happens let me no so i can add it to the package.

plus if i understood your explanation correctly two things can be done:
1- changing route re-renders the components inside <router-view> so in order for the menu to stay active you need to place the menu component out side of <router-view>(this is a common method) check the this code for demo
2- you can do it with the following menu list(by adding collapseOnClick = true to the parent) :

  {
       name: "Styling",
       icon: { class: "material-icons", text: "color_lens" },
        href: { path: "/styles/sass"}, // can also be vue-router object,
        collapseOnClick?: boolean //collapses menu when clicked - this behavior can also be achieved with Events
       children: [
         {
           name: "Sass Vars",
           href: { path: "/styles/sass"},
           icon: { class: "material-icons", text: "colorize" },
         },
         {
           name: "Css",
           href: { path: "/styles/css"},
           icon: { class: "material-icons", text: "css" },
         },
       ],
     },

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