-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
bug: ionic angular 7.5, cannot access menus with menuController #28337
Comments
Thanks for reporting this! I can reproduce the reported behavior. The problem is with the introduction of our standalone work, we now unintentionally create separate instances of the menuController. So the menu itself is registered with menuController A, but the application is using menuController B which is why As a temporary workaround, you can use |
Here's a dev build if you would like to test a proposed fix:
|
Issue number: resolves #28337 --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> Duplicate instances of `menuController` are being created in `@ionic/angular`. `ion-menu` registers itself in the `menuController` from `@ionic/core`, but the `MenuController` from `@ionic/angular` uses the `menuController` from `@ionic/core/components`. This is how the overlay providers work too. Normally, this is not a problem. However, `menuController` caches references to registered menus in each controller instances: https://github.com/ionic-team/ionic-framework/blob/dcbf45101f4c0dc3541cd4c19186daa3766a6ce7/core/src/utils/menu-controller/index.ts#L14 This means that since there are two different controllers, `menuController` B does not know about the menus in `menuController` A. The end result is that the menu controller used in developer applications did not have references to the registered menus, which gave the impression that the menu controller did not work. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Updated the architecture of `MenuController` in Ionic Angular to accept a `menuController` instance. This allows `@ionic/angular` to pass the `menuController` from `@ionic/core` and for `@ionic/angular/standalone` to pass the `menuController` from `@ionic/core/components`. Note: Overlay controllers don't **need** this change per-se since they don't cache references to overlays internally (they just query the DOM). However, I think it would be good to have a consistent architecture here, so I'll put up a separate PR that makes this change for overlays too. ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information Dev build: `7.5.1-dev.11697123035.1ee6b4a2` <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. -->
Thanks for the issue. This has been resolved via #28343, and a fix will be available in an upcoming release of Ionic Framework. Feel free to continue testing the dev build, and let me know if you have any questions! |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
Prerequisites
Ionic Framework Version
v7.x
Current Behavior
After upgrade @ionic/angular from 7.4.4 to 7.5.0 MenuController.enable() stop working.
Expected Behavior
A menu initially disabled should be enabled after calling enable(true) from MenuController on app.component.ts.
Steps to Reproduce
npm i @ionic/[email protected]
<ion-menu contentId="main-content" type="overlay" [disabled]="true">
ionic serve
and you will see the menu enabled (as expected).npm i @ionic/[email protected]
ionic serve
again and the menu will be disabled.Code Reproduction URL
https://stackblitz.com/edit/angular-lgwu3i?file=src%2Fapp%2Fapp.component.ts
Ionic Info
Ionic:
Ionic CLI : 7.1.1
Ionic Framework : @ionic/angular 7.5.0
@angular-devkit/build-angular : 16.2.6
@angular-devkit/schematics : 16.2.6
@angular/cli : 16.2.6
@ionic/angular-toolkit : 9.0.0
Capacitor:
Capacitor CLI : 5.5.0
@capacitor/android : not installed
@capacitor/core : 5.5.0
@capacitor/ios : not installed
Utility:
cordova-res : 0.15.4
native-run : 1.7.3
System:
NodeJS : v18.16.0 (C:\Program Files\nodejs\node.exe)
npm : 9.6.7
OS : Windows 10
Additional Information
No response
The text was updated successfully, but these errors were encountered: