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

Menubar, ContextMenu, TieredMenu warning #1029

Closed
cagataycivici opened this issue Feb 27, 2021 · 2 comments
Closed

Menubar, ContextMenu, TieredMenu warning #1029

cagataycivici opened this issue Feb 27, 2021 · 2 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@cagataycivici
Copy link
Member

runtime-core.esm-bundler.js?5c40:38 [Vue warn]: VNode created with invalid key (NaN). VNode type: Symbol(Fragment) 
  at <SubMenu model= (6) [{…}, {…}, {…}, {…}, {…}, {…}] root=true popup=false  ... > 
@cagataycivici cagataycivici added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Feb 27, 2021
@cagataycivici cagataycivici added this to the 3.3.2 milestone Feb 27, 2021
@cagataycivici cagataycivici self-assigned this Feb 27, 2021
@cagataycivici cagataycivici changed the title Menubar and TieredMenu warning Menubar, ContextMenu, TieredMenu warning Feb 27, 2021
@agm1984
Copy link

agm1984 commented Aug 19, 2022

I'm getting this error with the following code:

const items = ref([
    reactive({
        label: truncatedUserName,
        items: [
            { separator: true },
            {
                label: 'My Profile',
                icon: 'icon-profile',
                to: { name: 'login' },
            },
            {
                label: 'Log Out',
                icon: 'icon-logout',
                command: () => logout(),
            },
        ],
    }),
]);

const toggleMenu = (event) => {
    menu.value.toggle(event);
};

// ...

            <button
                id="nav-user-menu"
                class="w-10 h-10 flex items-center justify-center"
                aria-haspopup="true"
                aria-controls="overlay_menu"
                @click="toggleMenu"
            >
                <i class="icon-chevron-r icon-xl"></i>
            </button>

            <Menu ref="menu" :model="items" popup />

image

[Vue warn]: VNode created with invalid key (NaN). VNode type: Symbol(Fragment)

When I remove the heading in the menu items, the problem goes away.

@agm1984
Copy link

agm1984 commented Aug 19, 2022

Found it. It was actually caused by the separator. I removed that and the error went away, so something about having a separator as the first child subitem causes the error.

I looked at the code and it looks to be because the key attribute is based on the subitem's label, so I was able to fix the problem by assigning a label to the separator:

{ label: 'test', separator: true },

That also fixed the error.

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

2 participants