Repository navigation
Description
Prerequisites
- I have read the Contributing Guidelines.
- I agree to follow the Code of Conduct.
- I have searched for existing issues that already report this problem, without success.
Ionic Framework Version
v7.x
Current Behavior
We have an Angular website (v15) built with Ionic Framework v7 (latest version). The application worked perfectly fine until we installed Angular Universal (for SEO purposes). To make it work we also installed @ionic/angular-server (latest version).
We have a ion-menu inside a ion-split-pane that should be triggered by a ion-menu-button. If we launch the application using the command ionic serve the menu works fine but if we launch the application using the command npm run dev:ssr or npm run serve:ssr the menu isn't showing when clicking the ion-menu-button, so it's not an implementation problem but rather a bug.
There are also no errors in the browser console.
Keep in mind that the only issue we have is with the ion-menu-button, everything else works fine just like before using Angular Universal.
I can't disclose the full website code but here are the code fragments of the menu and the button :
ion-menu and ion-menu-button.txt
Does anyone else have the same problem? Is there any workaround to make it work?
Expected Behavior
When clicking the ion-menu-button, the related ion-menu should be displayed when launching the application using the commands npm run dev:ssr or npm run serve:ssr.
Steps to Reproduce
- Create a basic Angular application containing an ion-menu that should be opened by clicking an ion-menu-button.
- Launch the application using the command
ionic serveto verify that the menu is working correctly. - Install Angular Universal and launch the application using the commands
npm run dev:ssrornpm run serve:ssr. - Notice that the ion-menu won't be opened anymore.
Code Reproduction URL
No response
Ionic Info
Ionic:
Ionic CLI : 7.0.0 (C:\Users\giulia.bortot\AppData\Roaming\npm\node_modules@ionic\cli)
Ionic Framework : not installed
@angular-devkit/build-angular : 15.2.5
@angular-devkit/schematics : 12.2.18
@angular/cli : 15.2.5
@ionic/angular-toolkit : 4.0.0
Utility:
cordova-res : 0.15.4
native-run : 1.7.2
System:
NodeJS : v16.16.0 (C:\Program Files\nodejs\node.exe)
npm : 8.11.0
OS : Windows 10
Additional Information
No response
Activity
sean-perkins commentedon May 5, 2023
Hello @GiuliaBortot95 thanks for reporting this issue!
We do not have a lot of examples/documentation around
@ionic/angular-serversince it is a minimal implementation wrapper to hydrate the DOM for Ionic components in Angular Universal: https://github.com/ionic-team/ionic-framework/blob/main/packages/angular-server/src/ionic-server-module.tsYou could experiment with locally cloning this module and making changes, to see if it impacts your application behavior.
I would recommend excluding
ion-menu-buttonand see if it has an impact on the experience.GiuliaBortot95 commentedon May 10, 2023
I found the solution by myself while doing some tests. If anyone has the same issue, just do as follow:
<ion-menu-button menu="side" color="lili" auto-hide="false" (click)="toggleSideMenu()"></ion-menu-button>toggleSideMenu() { this.menuCtrl.toggle(); }Where menuCtrl is an instance of the Angular native MenuController (@angular/core):
constructor(public menuCtrl: MenuController)So basically just bypass the onclick event managed by Ionic.
Tvde1 commentedon Jul 11, 2023
Is this related to #27524?
sean-perkins commentedon Jul 17, 2023
I'm going to combine this issue with #22206. After investigation, the
ion-menu-buttondoesn't toggle as a result of being disabled after SSR.ionitron-bot commentedon Aug 16, 2023
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.