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

Remove vue-router support from Menu components #4739

Closed
10 tasks done
tugcekucukoglu opened this issue Nov 2, 2023 · 7 comments
Closed
10 tasks done

Remove vue-router support from Menu components #4739

tugcekucukoglu opened this issue Nov 2, 2023 · 7 comments
Assignees
Labels
Type: Breaking Change Issue contains a breaking change related to a specific component
Milestone

Comments

@tugcekucukoglu
Copy link
Member

tugcekucukoglu commented Nov 2, 2023

  • Breadcrumb
  • ContextMenu
  • Dock
  • Menu
  • Menubar
  • MegaMenu
  • PanelMenu
  • Steps
  • TabMenu
  • TieredMenu
@tugcekucukoglu tugcekucukoglu added this to the 4.0.0 milestone Nov 2, 2023
@tugcekucukoglu tugcekucukoglu added the Type: Breaking Change Issue contains a breaking change related to a specific component label Nov 2, 2023
@tugcekucukoglu tugcekucukoglu modified the milestones: 4.0.0, 3.40.0 Nov 8, 2023
@tugcekucukoglu tugcekucukoglu self-assigned this Nov 8, 2023
tugcekucukoglu added a commit that referenced this issue Nov 8, 2023
tugcekucukoglu added a commit that referenced this issue Nov 8, 2023
tugcekucukoglu added a commit that referenced this issue Nov 8, 2023
tugcekucukoglu added a commit that referenced this issue Nov 8, 2023
tugcekucukoglu added a commit that referenced this issue Nov 8, 2023
tugcekucukoglu added a commit that referenced this issue Nov 8, 2023
tugcekucukoglu added a commit that referenced this issue Nov 8, 2023
tugcekucukoglu added a commit that referenced this issue Nov 8, 2023
tugcekucukoglu added a commit that referenced this issue Nov 8, 2023
@Payn
Copy link

Payn commented Nov 14, 2023

Hello @tugcekucukoglu
how to use routing with TabMenu now? Or any other way to display different views based on active tab?
Thanks

@mikecbone
Copy link

@Payn You can do something like this:

<template>
  <TabMenu :model="menuItems" :active-index="activeMenuItemIndex">
    <template #item="{ item, props }">
      <router-link v-if="item.route" v-slot="{ href, navigate }" :to="item.route" custom>
        <a :href="href" v-bind="props.action" @click="navigate">
          <span :class="item.icon" />
          <span class="ml-2">{{ item.label }}</span>
        </a>
      </router-link>
    </template>
  </TabMenu>
</template>

<script setup>
import { ref, watch } from 'vue';
import { useRoute } from 'vue-router';

const route = useRoute();

const activeMenuItemIndex = ref(0);

const menuItems = [
  { label: 'MyTabOne', icon: 'pi pi-fw pi-code', route: '/tabone' },
  { label: 'MyTabTwo', icon: 'pi pi-fw pi-book', route: '/tabtwo' },
  { label: 'MyTabThree', icon: 'pi pi-fw pi-id-card', route: '/tabthree' },
];

watch(
  () => route.path,
  (updatedPath) => {
    activeMenuItemIndex.value = menuItems.findIndex((item) => updatedPath.startsWith(item.route));
  },
  { immediate: true }
);
</script>

The watch is similar to vue-routers active class. You could do something like

activeMenuItemIndex.value = menuItems.findIndex((item) => item.route === updatedPath );

for the exact active class.

@Payn
Copy link

Payn commented Nov 16, 2023

Awesome, this works. Thank you.

@Yonaro
Copy link

Yonaro commented Nov 28, 2023

Any reason on why this has been removed?

@vinodkola1337
Copy link

Any reason on why this has been removed?

You can find the explanation here.

@erropix
Copy link

erropix commented Jan 23, 2024

@tugcekucukoglu This is a breaking change and yet not mentioned in the 3.40 changelog?

@sey
Copy link

sey commented Apr 15, 2024

We just discovered about this change. I think it is a big issue to use semantic versioning and introduce a breaking change in minor version bump.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Breaking Change Issue contains a breaking change related to a specific component
Projects
None yet
Development

No branches or pull requests

7 participants