-
Notifications
You must be signed in to change notification settings - Fork 13.3k
fix(angular): do not create duplicate menuController instances #28343
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3f97b56
test(angular): add test
liamdebeasi d083a9c
fix(angular): do not create duplicate menuController instances
liamdebeasi ad5b271
add missing injectable
liamdebeasi ac21cc3
Revert
liamdebeasi c102863
add types
liamdebeasi fb772c6
remove injectable
liamdebeasi 8b8123f
fix promise
liamdebeasi ee6b4a2
clean up type
liamdebeasi 2e59f5b
Update menu-controller.spec.ts
liamdebeasi c506bb3
Update providers.spec.ts
liamdebeasi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { Injectable } from '@angular/core'; | ||
| import { MenuController as MenuControllerBase } from '@ionic/angular/common'; | ||
| import { menuController } from '@ionic/core'; | ||
|
|
||
| @Injectable({ | ||
| providedIn: 'root', | ||
| }) | ||
| export class MenuController extends MenuControllerBase { | ||
| constructor() { | ||
| super(menuController); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
packages/angular/standalone/src/providers/menu-controller.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { Injectable } from '@angular/core'; | ||
| import { MenuController as MenuControllerBase } from '@ionic/angular/common'; | ||
| import { menuController } from '@ionic/core/components'; | ||
|
|
||
| @Injectable({ | ||
| providedIn: 'root', | ||
| }) | ||
| export class MenuController extends MenuControllerBase { | ||
| constructor() { | ||
| super(menuController); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
packages/angular/test/base/e2e/src/standalone/menu-controller.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| describe('Menu Controller', () => { | ||
| beforeEach(() => { | ||
| cy.visit('/standalone/menu-controller'); | ||
| }) | ||
|
|
||
| // https://github.com/ionic-team/ionic-framework/issues/28337 | ||
| it('should register menus correctly', () => { | ||
| cy.get('#set-menu-count').click(); | ||
| cy.get('#registered-menu-count').should('have.text', '1'); | ||
| }); | ||
| }) |
85 changes: 47 additions & 38 deletions
85
packages/angular/test/base/src/app/lazy/providers/providers.component.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,48 @@ | ||
| <ion-menu menu-id="menu" content-id="content"> | ||
| Menu Content | ||
| </ion-menu> | ||
|
|
||
| <ion-header> | ||
| <ion-toolbar> | ||
| <ion-title> | ||
| Providers Test | ||
| </ion-title> | ||
| </ion-toolbar> | ||
| </ion-header> | ||
| <ion-content class="ion-padding"> | ||
| <p> | ||
| isLoaded: <span id="is-loaded">{{isLoaded}}</span> | ||
| </p> | ||
| <p> | ||
| isReady: <span id="is-ready">{{isReady}}</span> | ||
| </p> | ||
| <p> | ||
| isResumed: <span id="is-resumed">{{isResumed}}</span> | ||
| </p> | ||
| <p> | ||
| isPaused: <span id="is-paused">{{isPaused}}</span> | ||
| </p> | ||
| <p> | ||
| isResized: <span id="is-resized">{{isResized}}</span> | ||
| </p> | ||
| <p> | ||
| isTesting: <span id="is-testing">{{isTesting}}</span> | ||
| </p> | ||
| <p> | ||
| isDesktop: <span id="is-desktop">{{isDesktop}}</span> | ||
| </p> | ||
| <p> | ||
| isMobile: <span id="is-mobile">{{isMobile}}</span> | ||
| </p> | ||
| <p> | ||
| keyboardHeight: <span id="keyboard-height">{{keyboardHeight}}</span> | ||
| </p> | ||
| <p> | ||
| queryParams: <span id="query-params">{{queryParams}}</span> | ||
| </p> | ||
| </ion-content> | ||
| <ion-toolbar> | ||
| <ion-title> | ||
| Providers Test | ||
| </ion-title> | ||
| </ion-toolbar> | ||
| </ion-header> | ||
| <ion-content class="ion-padding" id="content"> | ||
| <p> | ||
| isLoaded: <span id="is-loaded">{{isLoaded}}</span> | ||
| </p> | ||
| <p> | ||
| isReady: <span id="is-ready">{{isReady}}</span> | ||
| </p> | ||
| <p> | ||
| isResumed: <span id="is-resumed">{{isResumed}}</span> | ||
| </p> | ||
| <p> | ||
| isPaused: <span id="is-paused">{{isPaused}}</span> | ||
| </p> | ||
| <p> | ||
| isResized: <span id="is-resized">{{isResized}}</span> | ||
| </p> | ||
| <p> | ||
| isTesting: <span id="is-testing">{{isTesting}}</span> | ||
| </p> | ||
| <p> | ||
| isDesktop: <span id="is-desktop">{{isDesktop}}</span> | ||
| </p> | ||
| <p> | ||
| isMobile: <span id="is-mobile">{{isMobile}}</span> | ||
| </p> | ||
| <p> | ||
| keyboardHeight: <span id="keyboard-height">{{keyboardHeight}}</span> | ||
| </p> | ||
| <p> | ||
| queryParams: <span id="query-params">{{queryParams}}</span> | ||
| </p> | ||
| <p> | ||
| Registered Menu Count: <span id="registered-menu-count">{{registeredMenuCount}}</span> | ||
| </p> | ||
|
|
||
| <button id="set-menu-count" (click)="setMenuCount()">Set Menu Count</button> | ||
| </ion-content> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
packages/angular/test/base/src/app/standalone/menu-controller/menu-controller.component.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <ion-menu menu-id="menu" content-id="content"> | ||
| Menu Content | ||
| </ion-menu> | ||
|
|
||
| <ul id="content"> | ||
| <li>Registered Menu Count: <span id="registered-menu-count">{{registeredMenuCount}}</span></li> | ||
|
|
||
| <button id="set-menu-count" (click)="setMenuCount()">Set Menu Count</button> | ||
| </ul> | ||
|
|
19 changes: 19 additions & 0 deletions
19
packages/angular/test/base/src/app/standalone/menu-controller/menu-controller.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { Component } from '@angular/core'; | ||
| import { MenuController, IonMenu } from '@ionic/angular/standalone'; | ||
|
|
||
| @Component({ | ||
| selector: 'app-menu-controller', | ||
| templateUrl: './menu-controller.component.html', | ||
| standalone: true, | ||
| imports: [IonMenu] | ||
| }) | ||
| export class MenuControllerComponent { | ||
| registeredMenuCount = 0; | ||
|
|
||
| constructor(private menuCtrl: MenuController) {} | ||
|
|
||
| async setMenuCount() { | ||
| const menus = await this.menuCtrl.getMenus(); | ||
| this.registeredMenuCount = menus.length; | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getOpenSyncdoesn't actually exist on the menu controller. However,_getOpenSyncdoes so I think this was a typo.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!