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 components with web router refresh the whole page #536

Closed
LadislavBohm opened this issue Oct 9, 2020 · 6 comments
Closed

Menu components with web router refresh the whole page #536

LadislavBohm opened this issue Oct 9, 2020 · 6 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@LadislavBohm
Copy link

LadislavBohm commented Oct 9, 2020

I use Menubar component as my top level navigation bar but even when I use to property on my menu items clicking any of them still causes whole page to refresh.

I think the problem is that you are using @click event on like this:

<router-link v-if="item.to && !item.disabled" :to="item.to" :class="getLinkClass(item)" v-ripple
                    @click="onItemClick($event, item)" @keydown="onItemKeyDown($event, item)" role="menuitem">
                    <span :class="['p-menuitem-icon', item.icon]"></span>
                    <span class="p-menuitem-text">{{item.label}}</span>
</router-link>

After removing this @click handler it started to work properly. This happens on Vue 3 with vue-router version 4.0.0-beta.13.

@cagataycivici
Copy link
Member

I'm unable to replicate, can you please also provide your menumodel?

@cagataycivici cagataycivici added the Resolution: Cannot Replicate Issue could not be replicated by Core Team label Oct 10, 2020
@LadislavBohm
Copy link
Author

Sure, I pass menu items from setup() method like this:

const menuItems = ref([
      {
        label: "Home",
        icon: "pi pi-home",
        to: "/"
      },
      {
        label: "Users",
        icon: "pi pi-users",
        to: "/users"
      },
      {
        label: "Reports",
        icon: "pi pi-print",
        to: "/reports"
      }
    ] as Array<MenuItem>);

and then use it in my template like this:

<Menubar class="p-shadow-2" :model="menuItems"></Menubar>

There is nothing else in my template or component. Router is setup in a standard way. Issue went away when I manually removed @click="onItemClick($event, item)" from in MenubarSub, probably because it did not call preventDefault in this case?

@LadislavBohm
Copy link
Author

@cagataycivici I created repository that reproduces this bug. It's the simplest example I can think of with just two routes, this menubar and every time you click on it it refreshes whole page:
https://github.com/LadislavBohm/primevue-menubar-reload

I wasn't able to make primevue work in codesandbox. If you have it setup there it would be nice to share it so we can easily fork it and use it next time.

@cagataycivici cagataycivici self-assigned this Oct 21, 2020
@cagataycivici cagataycivici removed the Resolution: Cannot Replicate Issue could not be replicated by Core Team label Oct 21, 2020
@cagataycivici cagataycivici added this to the 3.0.1 milestone Oct 21, 2020
@cagataycivici cagataycivici added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Oct 21, 2020
@cagataycivici
Copy link
Member

I'll check, thank you.

@cagataycivici cagataycivici changed the title Menubar items with 'to' refresh the whole page Menu components with web router refresh the whole page Oct 22, 2020
@cagataycivici
Copy link
Member

Resolved it for all menu components.

@DaveBruwer
Copy link

this behaviour is still present to this day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

3 participants