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.vue: seperatorClass is not a function #3151

Closed
DotoPototo opened this issue Oct 24, 2022 · 0 comments
Closed

Menu.vue: seperatorClass is not a function #3151

DotoPototo opened this issue Oct 24, 2022 · 0 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@DotoPototo
Copy link

Describe the bug

"primeflex": "^3.2.1",
"primeicons": "^6.0.1",
"primevue": "^3.18.0",
"vue": "^3.2.41",

When adding a separator to a menu, it errors out.

const menuItems = ref([
  {
    label: 'Example',
    icon: 'pi pi-info-circle',
    command: () => {
      //....
    },
  },
  {
    separator: true,
  },
  {
    label: 'Example',
    icon: 'pi pi-info-circle',
    command: () => {
      //....
    },
  },
]);
menu.esm.js:582 Uncaught (in promise) TypeError: $options.separatorClass is not a function at menu.esm.js:582:62

In primevue 3.18.0, it looks like the way a class is added to a menu separator changed. It now calls a computed property separatorClass to provide the class value, passing in the item.

<li v-else-if="visible(item) && item.separator" :key="'separator' + i.toString()" :class="separatorClass(item)" :style="item.style" role="separator"></li>

I think the problem is down to the computed property not accepting an argument properly.

separatorClass(item) {
  return ['p-menu-separator p-menuitem-separator', item.class]; // TODO: the 'p-menu-separator' class is deprecated since v3.18.0.
},

As far as I understand it, for a computed property to accept an argument the computed property needs to return a function that then accepts an argument.

separatorClass() {
  return (item) => ['p-menu-separator p-menuitem-separator', item.class]; // TODO: the 'p-menu-separator' class is deprecated since v3.18.0.
},

Reproducer

https://codesandbox.io/s/white-frog-uoxueu?file=/src/App.vue

PrimeVue version

3.18.0

Vue version

3.x

Language

ALL

Build / Runtime

Vite

Browser(s)

Chrome

Steps to reproduce the behavior

No response

Expected behavior

No response

@DotoPototo DotoPototo added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Oct 24, 2022
@mertsincan mertsincan added this to the 3.18.1 milestone Oct 24, 2022
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