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 | ReferenceError: Cannot access 'Menubar' before initialization #13024

Closed
VallarasuS opened this issue May 11, 2023 · 17 comments · Fixed by #13429
Closed

Menubar | ReferenceError: Cannot access 'Menubar' before initialization #13024

VallarasuS opened this issue May 11, 2023 · 17 comments · Fixed by #13429
Assignees
Labels
Component: Test Issue or pull request is related to Component Testing Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@VallarasuS
Copy link

Description

Existing tests fail with the following error

ReferenceError: Cannot access 'Menubar' before initialization

import { MenubarModule } from 'primeng/menubar';

Environment
Windows Jest tests

Angular Version
15.2.3

Primeng Version
15.4.0

Build / Runtime
Angular CLI App

Language
TypeScript

Steps to Reproduce

  1. import { MenubarModule } from 'primeng/menubar';
  2. run npm test

Expected behavior
Exoect the tests to run without the error in subject.

@github-actions github-actions bot added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label May 11, 2023
@AndreasHae
Copy link

AndreasHae commented May 11, 2023

I have the same issue after upgrading to primeng 15.4.1 and Angular 15.2.9. The application builds and runs fine, but when executing tests via Jest, I get hit with ReferenceError: Cannot access 'Menubar' before initialization.

Update: I'm not experiencing the issue on primeng 15.3.0

@andresciceri
Copy link

Hi, I have the same issue but with the PanelMenu. I've been searching in the Prime issues and I found the same issue in #11931 but there isn't a real solution. My primeng version is 15.4.1.

Do you recommend downgrade the primeng version?

ReferenceError: Cannot access 'PanelMenu' before initialization

@213edu
Copy link
Contributor

213edu commented May 14, 2023

+1 on 15.4.1

@cetincakiroglu cetincakiroglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels May 16, 2023
@cetincakiroglu cetincakiroglu added this to the 16.0.0 milestone May 16, 2023
@bendehghan
Copy link

Another one for splitbutton #12945

@cetincakiroglu cetincakiroglu modified the milestones: 16.0.0-rc.2, 16.0.0 May 19, 2023
@bcandullo
Copy link

This is still an issue in 16.0.0-rc.1 and 16.0.0-rc.2.

@blackholegalaxy
Copy link

@cetincakiroglu this bug is blocking basically any usage of Menu module. Including split button module. From 15.4.1 and up.
Can we expect any fix soon?

@cetincakiroglu
Copy link
Contributor

cetincakiroglu commented Jun 7, 2023

Thanks for reporting, we're investigating the issue. Possible fix would be available 16.0.0 or 16.0.1 release.

@cetincakiroglu cetincakiroglu modified the milestones: 16.0.0, 16.0.1, 16.Future Jun 12, 2023
@Thomas-Schindler
Copy link

Hi,
we have the same problem here. We want to migrate from Angular 14 to Angular 15 using PrimeNG 15.4.0. When we try to run our unit tests with jest (version ^28.0.0), whe get the error message on each test of an Angular component referencing a PrimeNG component.

`Test suite failed to run

ReferenceError: Cannot access 'PanelMenu' before initialization

  10 | import { SelectButtonModule } from 'primeng/selectbutton';
  11 | import { BreadcrumbModule } from 'primeng/breadcrumb';
  12 | import { PanelMenuModule } from 'primeng/panelmenu';

`
Downgrading to PrimeNG 15.3.0 fixed the problem. But of course would we like to use ^15.4.1 in the future. Is there any chance to get a fix in 15.4.x?

@Thomas-Schindler
Copy link

Hello,

we have experienced the same problem when migrating from Angular 14 and PrimeNG 14 to Angular 15.2.9 and PrimeNG 15.4.1. A workaround for us is to use PrimeNG 15.3.0. But of course we would like to get also the fixes and enhancements made ein 15.4.x. Is there a change that a fix is available also for 15.4.x?

@HMubaireek
Copy link

The issue still appears in 16.0.2

@psarno
Copy link

psarno commented Jul 30, 2023

I am attempting to create a repro for another issue in StackBlitz but am getting the following:

Error in /turbo_modules/primeng@16.1.0/fesm2022/primeng-contextmenu.mjs (144:254)
Cannot access 'ContextMenu' before initialization

I am tryng to update the repro template to use the latest PrimeNG (16.1.0) but it won't render my <p-menubar> component after updating the template from 14 -> 16.1.

I'm not dealing with a context menu at all.

@umuero
Copy link
Contributor

umuero commented Aug 4, 2023

The issue spread to ContextMenuModule with commit #f4f3598

constructor(@Inject(forwardRef(() => ContextMenu)) contextMenu: ContextMenu)
was working

constructor(...., public contextMenu: ContextMenu)
fails

@cetincakiroglu cetincakiroglu added the Component: Test Issue or pull request is related to Component Testing label Aug 11, 2023
@cetincakiroglu cetincakiroglu modified the milestones: 16.2.0, 16.Future Aug 11, 2023
@cetincakiroglu
Copy link
Contributor

cetincakiroglu commented Aug 11, 2023

Hi,

We're currently working on accessibility and in this process, we are refactoring & reworking all of the components, because of that all tests need to be refactored afterwards. I'm moving this issue to 16.Future milestone and after we finalize accessibility implementation we'll take this issue into consideration while we fixing the tests.

Thanks for reporting the issue!

@Torquin
Copy link

Torquin commented Aug 21, 2023

Hi @cetincakiroglu,
Any ETA for these updates. Got it working by modifying frontend/node_modules/primeng/fesm2022/primeng-tieredmenu.mjs but this is obviously not the correct way to go.

Thanks

@mertsincan mertsincan modified the milestones: 16.Future, 16.2.1 Aug 26, 2023
@psarno
Copy link

psarno commented Sep 9, 2023

I still am having trouble trying to get a Stackblitz up and running for version 16.

All of the dependencies are where they should be, but the error I am seeing now is:

Error in /turbo_modules/primeng@16.3.1/fesm2022/primeng-tieredmenu.mjs (137:252)

Cannot access 'TieredMenu' before initialization

No menus are being used ... in fact the template is completely empty.

The call stack seems to originate in primeng-splitbutton.mjs before failing in tieredmenu.mjs?

Unhandled Promise rejection:
Cannot access 'TieredMenu' before initialization
Error: Cannot access 'TieredMenu' before initialization
ReferenceError: Cannot access 'TieredMenu' before initialization
at Object.eval (primeng-tieredmenu.mjs:137:252)
at eval (primeng-tieredmenu.mjs:1219:4)
at eval (primeng-tieredmenu.mjs:1220:3)
at Object.eval (primeng-splitbutton.mjs:35:25)
at eval (primeng-splitbutton.mjs:251:4)

@livanov
Copy link

livanov commented Nov 26, 2023

Still having issues with PanelMenu in Angular 16, primeng 16.9

anninowak added a commit to anninowak/onecx-portal-ui-libs that referenced this issue Dec 13, 2023
The primeNG version 15.2.1 was the last version where this issue
primefaces/primeng#13024 was not occuring for us

Before upgrading this version, please check if the tests are running with
npx nx affected -t test --configuration=ci --skip-nx-cache
anninowak added a commit to onecx/onecx-portal-ui-libs that referenced this issue Dec 14, 2023
* feat: P002271-6127 emit SearchConfig

* feat: add additionalToolBarActions to page header and to search header

* feat: hardcoded search config as a template
and provided with translations

* feat: test harness adapted and tests added

* fix: remove unused imports and variables

* fix: rename defaultTranslationKey to
 placeholderKey

* fix: adaption of the action version

* fix: change primeng version back

* fix: downgrading primeNG version

The primeNG version 15.2.1 was the last version where this issue
primefaces/primeng#13024 was not occuring for us

Before upgrading this version, please check if the tests are running with
npx nx affected -t test --configuration=ci --skip-nx-cache

* fix: add missing test to check if the dropdown
disappears when the searchconfig is empty
@pdemro
Copy link

pdemro commented Feb 14, 2024

+1 for 15.4.0 :( . Downgrading to 15.3.0 solves the issue

p.s. thanks for the great library ♥️

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

Successfully merging a pull request may close this issue.