Skip to content

Commit c5dd622

Browse files
authored
refactor(angular): action sheet provider imports correct instance from core (#28474)
Issue number: N/A --------- <!-- 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. --> As a takeaway from our learning session about a menuController bug in Ionic Angular, the team would like to update our other providers to use the same architecture as the menuController to prevent this kind of issue from happening again in the future. We also noticed that the common provider does not provide much value and it's easier to just have two separate implementations in `src` and `standalone`. (There wasn't much code we could de-duplicate) ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Removed the common action sheet provider in favor of separate ones in src/standalone ## 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 <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. -->
1 parent c053fd9 commit c5dd622

File tree

12 files changed

+70
-6
lines changed

12 files changed

+70
-6
lines changed

packages/angular/common/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
export { ActionSheetController } from './providers/action-sheet-controller';
21
export { AlertController } from './providers/alert-controller';
32
export { LoadingController } from './providers/loading-controller';
43
export { MenuController } from './providers/menu-controller';
@@ -39,5 +38,6 @@ export * from './directives/control-value-accessors';
3938
export { ProxyCmp } from './utils/proxy';
4039

4140
export { IonicRouteStrategy } from './utils/routing';
41+
export { OverlayBaseController } from './utils/overlay';
4242

4343
export { raf } from './utils/util';

packages/angular/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export * from './directives/validators';
2020

2121
// PROVIDERS
2222
export {
23-
ActionSheetController,
2423
AlertController,
2524
LoadingController,
2625
ModalController,
@@ -42,6 +41,7 @@ export {
4241
ViewDidLeave,
4342
} from '@ionic/angular/common';
4443
export { MenuController } from './providers/menu-controller';
44+
export { ActionSheetController } from './providers/action-sheet-controller';
4545

4646
// PACKAGE MODULE
4747
export { IonicModule } from './ionic-module';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Injectable } from '@angular/core';
2+
import { OverlayBaseController } from '@ionic/angular/common';
3+
import type { ActionSheetOptions } from '@ionic/core';
4+
import { actionSheetController } from '@ionic/core';
5+
6+
@Injectable({
7+
providedIn: 'root',
8+
})
9+
export class ActionSheetController extends OverlayBaseController<ActionSheetOptions, HTMLIonActionSheetElement> {
10+
constructor() {
11+
super(actionSheetController);
12+
}
13+
}

packages/angular/standalone/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ export { IonRouterLink, IonRouterLinkWithHref } from './navigation/router-link-d
66
export { IonTabs } from './navigation/tabs';
77
export { provideIonicAngular } from './providers/ionic-angular';
88
export { MenuController } from './providers/menu-controller';
9+
export { ActionSheetController } from './providers/action-sheet-controller';
910
export {
10-
ActionSheetController,
1111
AlertController,
1212
LoadingController,
1313
ModalController,

packages/angular/common/src/providers/action-sheet-controller.ts renamed to packages/angular/standalone/src/providers/action-sheet-controller.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { Injectable } from '@angular/core';
2+
import { OverlayBaseController } from '@ionic/angular/common';
23
import type { ActionSheetOptions } from '@ionic/core/components';
34
import { actionSheetController } from '@ionic/core/components';
45

5-
import { OverlayBaseController } from '../utils/overlay';
6-
76
@Injectable({
87
providedIn: 'root',
98
})

packages/angular/test/base/e2e/src/lazy/providers.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,11 @@ describe('Providers', () => {
3333
cy.get('#set-menu-count').click();
3434
cy.get('#registered-menu-count').should('have.text', '1');
3535
});
36+
37+
it('should open an action sheet', () => {
38+
cy.get('button#open-action-sheet').click();
39+
40+
cy.get('ion-action-sheet').should('be.visible');
41+
});
3642
});
3743

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
describe('Action Sheet Controller', () => {
2+
beforeEach(() => {
3+
cy.visit('/standalone/action-sheet-controller');
4+
})
5+
6+
it('should open an action sheet', () => {
7+
cy.get('button#open-action-sheet').click();
8+
9+
cy.get('ion-action-sheet').should('be.visible');
10+
});
11+
})

packages/angular/test/base/src/app/lazy/providers/providers.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@
4545
</p>
4646

4747
<button id="set-menu-count" (click)="setMenuCount()">Set Menu Count</button>
48+
<button id="open-action-sheet" (click)="openActionSheet()">Open Action Sheet</button>
4849
</ion-content>

packages/angular/test/base/src/app/lazy/providers/providers.component.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class ProvidersComponent {
2424
registeredMenuCount = 0;
2525

2626
constructor(
27-
actionSheetCtrl: ActionSheetController,
27+
private actionSheetCtrl: ActionSheetController,
2828
alertCtrl: AlertController,
2929
loadingCtrl: LoadingController,
3030
private menuCtrl: MenuController,
@@ -88,4 +88,12 @@ export class ProvidersComponent {
8888
const menus = await this.menuCtrl.getMenus();
8989
this.registeredMenuCount = menus.length;
9090
}
91+
92+
async openActionSheet() {
93+
const actionSheet = await this.actionSheetCtrl.create({
94+
buttons: ['Button']
95+
});
96+
97+
await actionSheet.present();
98+
}
9199
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<ul id="content">
2+
<button id="open-action-sheet" (click)="openActionSheet()">Open Action Sheets</button>
3+
</ul>
4+

0 commit comments

Comments
 (0)