11<template >
2- <Menubar ref =" menuBar " :id =" props.id" :model =" items" >
2+ <Menubar ref =" menuBarRef " :id =" props.id" :model =" items" >
33 <template #item =" { item , props } " >
44 <a v-bind =" props.action" >
55 <div class =" p-menubar-item-label" >{{ item.label }}</div >
@@ -152,13 +152,13 @@ const items = [
152152
153153// A few things that can only be done when the component is mounted.
154154
155- const menuBar = vue .ref <(vue . ComponentPublicInstance <typeof Menubar > & { hide: () => void }) | null >(null );
155+ const menuBarRef = vue .ref <(InstanceType <typeof Menubar > & { hide: () => void ; $el : HTMLElement }) | null >(null );
156156
157157vue .onMounted (() => {
158- if (menuBar .value ) {
158+ if (menuBarRef .value ) {
159159 // Ensure that the menubar never gets the 'p-menubar-mobile' class, which would turn it into a hamburger menu.
160160
161- const menuBarElement = menuBar .value .$el as HTMLElement ;
161+ const menuBarElement = menuBarRef .value .$el ;
162162 const mutationObserver = new MutationObserver (() => {
163163 if (menuBarElement .classList .contains (' p-menubar-mobile' )) {
164164 menuBarElement .classList .remove (' p-menubar-mobile' );
@@ -167,7 +167,7 @@ vue.onMounted(() => {
167167
168168 mutationObserver .observe (menuBarElement , { attributes: true , attributeFilter: [' class' ] });
169169
170- // Close the menu when clicking clicking on the menubar but outside of the main menu items.
170+ // Close the menu when clicking on the menubar but outside of the main menu items.
171171
172172 const onClick = (event : MouseEvent ) => {
173173 const target = event .target as Node ;
@@ -177,7 +177,7 @@ vue.onMounted(() => {
177177 ! menuBarElement .querySelector (' .p-menubar-root-list' )?.contains (target ) &&
178178 ! Array .from (document .querySelectorAll (' .p-menubar-submenu' )).some ((submenu ) => submenu .contains (target ))
179179 ) {
180- menuBar .value ?.hide ();
180+ menuBarRef .value ?.hide ();
181181 }
182182 };
183183
0 commit comments