Skip to content

Commit adb01e2

Browse files
authored
refactor(angular): loading controller uses correct core instance (#28543)
Issue number: Internal --------- <!-- 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? 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 loading 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 4f1b4cd commit adb01e2

File tree

11 files changed

+61
-7
lines changed

11 files changed

+61
-7
lines changed

packages/angular/common/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
export { LoadingController } from './providers/loading-controller';
21
export { MenuController } from './providers/menu-controller';
32
export { DomController } from './providers/dom-controller';
43
export { NavController } from './providers/nav-controller';

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-
LoadingController,
2423
DomController,
2524
NavController,
2625
Config,
@@ -37,6 +36,7 @@ export { AlertController } from './providers/alert-controller';
3736
export { AnimationController } from './providers/animation-controller';
3837
export { ActionSheetController } from './providers/action-sheet-controller';
3938
export { GestureController } from './providers/gesture-controller';
39+
export { LoadingController } from './providers/loading-controller';
4040
export { MenuController } from './providers/menu-controller';
4141
export { ModalController } from './providers/modal-controller';
4242
export { PickerController } from './providers/picker-controller';
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 { LoadingOptions } from '@ionic/core';
4+
import { loadingController } from '@ionic/core';
5+
6+
@Injectable({
7+
providedIn: 'root',
8+
})
9+
export class LoadingController extends OverlayBaseController<LoadingOptions, HTMLIonLoadingElement> {
10+
constructor() {
11+
super(loadingController);
12+
}
13+
}

packages/angular/standalone/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ export { ActionSheetController } from './providers/action-sheet-controller';
99
export { AlertController } from './providers/alert-controller';
1010
export { AnimationController } from './providers/animation-controller';
1111
export { GestureController } from './providers/gesture-controller';
12+
export { LoadingController } from './providers/loading-controller';
1213
export { MenuController } from './providers/menu-controller';
1314
export { ModalController } from './providers/modal-controller';
1415
export { PickerController } from './providers/picker-controller';
1516
export { PopoverController } from './providers/popover-controller';
1617
export { ToastController } from './providers/toast-controller';
1718
export {
18-
LoadingController,
1919
DomController,
2020
NavController,
2121
Config,
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import { Injectable } from '@angular/core';
2+
import { OverlayBaseController } from '@ionic/angular/common';
23
import type { LoadingOptions } from '@ionic/core/components';
34
import { loadingController } from '@ionic/core/components';
4-
5-
import { OverlayBaseController } from '../utils/overlay';
5+
import { defineCustomElement } from '@ionic/core/components/ion-loading.js';
66

77
@Injectable({
88
providedIn: 'root',
99
})
1010
export class LoadingController extends OverlayBaseController<LoadingOptions, HTMLIonLoadingElement> {
1111
constructor() {
1212
super(loadingController);
13+
14+
// TODO: FW-5415 may remove the need for this
15+
defineCustomElement();
1316
}
1417
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ describe('Providers', () => {
4646
cy.get('ion-alert').should('be.visible');
4747
});
4848

49+
it('should open a loading-indicator', () => {
50+
cy.get('button#open-loading').click();
51+
52+
cy.get('ion-loading').should('be.visible');
53+
});
54+
4955
it('should open a picker', () => {
5056
cy.get('button#open-picker').click();
5157

packages/angular/test/base/e2e/src/standalone/overlay-controllers.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ describe('Overlay Controllers', () => {
99
cy.get('ion-alert').should('be.visible');
1010
});
1111

12+
it('should present a loading indicator', () => {
13+
cy.get('button#open-loading').click();
14+
15+
cy.get('ion-loading').should('be.visible');
16+
});
17+
1218
it('should present a modal', () => {
1319
cy.get('button#open-modal').click();
1420

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
@@ -47,5 +47,6 @@
4747
<button id="set-menu-count" (click)="setMenuCount()">Set Menu Count</button>
4848
<button id="open-alert" (click)="openAlert()">Open Alert</button>
4949
<button id="open-action-sheet" (click)="openActionSheet()">Open Action Sheet</button>
50+
<button id="open-loading" (click)="openLoading()">Open Loading Indicator</button>
5051
<button id="open-picker" (click)="openPicker()">Open Picker</button>
5152
</ion-content>

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class ProvidersComponent {
3434
constructor(
3535
private actionSheetCtrl: ActionSheetController,
3636
private alertCtrl: AlertController,
37-
loadingCtrl: LoadingController,
37+
private loadingCtrl: LoadingController,
3838
private menuCtrl: MenuController,
3939
private pickerCtrl: PickerController,
4040
modalCtrl: ModalController,
@@ -129,6 +129,15 @@ export class ProvidersComponent {
129129
await alert.present();
130130
}
131131

132+
async openLoading() {
133+
const loading = await this.loadingCtrl.create({
134+
message: 'Loading...',
135+
duration: 2000,
136+
});
137+
138+
await loading.present();
139+
}
140+
132141
async openPicker() {
133142
const picker = await this.pickerCtrl.create({
134143
columns: [],

packages/angular/test/base/src/app/standalone/overlay-controllers/overlay-controllers.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<div>
22
<button id="open-alert" (click)="openAlert()">Open Alert</button>
3+
<button id="open-loading" (click)="openLoading()">Open Loading Indicator</button>
34
<button id="open-modal" (click)="openModal()">Open Modal</button>
45
<button id="open-picker" (click)="openPicker()">Open Picker</button>
56
<button id="open-popover" (click)="openPopover($event)">Open Popover</button>

0 commit comments

Comments
 (0)