Skip to content

Commit c1304b7

Browse files
authored
refactor(angular): popover controller uses correct core instance (#28485)
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? <!-- 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 popover 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. --> I didn't add tests because there's already existing ones for popover controller.
1 parent c5dd622 commit c1304b7

File tree

8 files changed

+31
-24
lines changed

8 files changed

+31
-24
lines changed

packages/angular/common/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ export { LoadingController } from './providers/loading-controller';
33
export { MenuController } from './providers/menu-controller';
44
export { ModalController } from './providers/modal-controller';
55
export { PickerController } from './providers/picker-controller';
6-
export { PopoverController } from './providers/popover-controller';
76
export { ToastController } from './providers/toast-controller';
87

98
export { AnimationController } from './providers/animation-controller';

packages/angular/common/src/utils/overlay.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// TODO(FW-2827): types
22

3-
interface ControllerShape<Opts, HTMLElm> {
3+
export interface ControllerShape<Opts, HTMLElm> {
44
create(options: Opts): Promise<HTMLElm>;
55
dismiss(data?: any, role?: string, id?: string): Promise<boolean>;
66
getTop(): Promise<HTMLElm | undefined>;

packages/angular/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export {
2424
LoadingController,
2525
ModalController,
2626
PickerController,
27-
PopoverController,
2827
ToastController,
2928
AnimationController,
3029
GestureController,
@@ -41,6 +40,7 @@ export {
4140
ViewDidLeave,
4241
} from '@ionic/angular/common';
4342
export { MenuController } from './providers/menu-controller';
43+
export { PopoverController } from './providers/popover-controller';
4444
export { ActionSheetController } from './providers/action-sheet-controller';
4545

4646
// PACKAGE MODULE

packages/angular/src/ionic-module.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
import { CommonModule, DOCUMENT } from '@angular/common';
22
import { ModuleWithProviders, APP_INITIALIZER, NgModule, NgZone } from '@angular/core';
3-
import {
4-
ModalController,
5-
PopoverController,
6-
ConfigToken,
7-
AngularDelegate,
8-
provideComponentInputBinding,
9-
} from '@ionic/angular/common';
3+
import { ModalController, ConfigToken, AngularDelegate, provideComponentInputBinding } from '@ionic/angular/common';
104
import { IonicConfig } from '@ionic/core';
115

126
import { appInitialize } from './app-initialize';
@@ -29,6 +23,7 @@ import { IonModal } from './directives/overlays/modal';
2923
import { IonPopover } from './directives/overlays/popover';
3024
import { DIRECTIVES } from './directives/proxies-list';
3125
import { IonMaxValidator, IonMinValidator } from './directives/validators';
26+
import { PopoverController } from './providers/popover-controller';
3227

3328
const DECLARATIONS = [
3429
// generated proxies
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { Injector, inject, EnvironmentInjector } from '@angular/core';
2+
import { AngularDelegate, OverlayBaseController } from '@ionic/angular/common';
3+
import type { PopoverOptions } from '@ionic/core';
4+
import { popoverController } from '@ionic/core';
5+
6+
export class PopoverController extends OverlayBaseController<PopoverOptions, HTMLIonPopoverElement> {
7+
private angularDelegate = inject(AngularDelegate);
8+
private injector = inject(Injector);
9+
private environmentInjector = inject(EnvironmentInjector);
10+
11+
constructor() {
12+
super(popoverController);
13+
}
14+
15+
create(opts: PopoverOptions): Promise<HTMLIonPopoverElement> {
16+
return super.create({
17+
...opts,
18+
delegate: this.angularDelegate.create(this.environmentInjector, this.injector, 'popover'),
19+
});
20+
}
21+
}

packages/angular/standalone/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ 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 { PopoverController } from './providers/popover-controller';
910
export { ActionSheetController } from './providers/action-sheet-controller';
1011
export {
1112
AlertController,
1213
LoadingController,
1314
ModalController,
1415
PickerController,
15-
PopoverController,
1616
ToastController,
1717
AnimationController,
1818
GestureController,

packages/angular/standalone/src/providers/ionic-angular.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
import { DOCUMENT } from '@angular/common';
22
import { APP_INITIALIZER } from '@angular/core';
33
import type { Provider } from '@angular/core';
4-
import {
5-
AngularDelegate,
6-
ConfigToken,
7-
ModalController,
8-
PopoverController,
9-
provideComponentInputBinding,
10-
} from '@ionic/angular/common';
4+
import { AngularDelegate, ConfigToken, ModalController, provideComponentInputBinding } from '@ionic/angular/common';
115
import { initialize } from '@ionic/core/components';
126
import type { IonicConfig } from '@ionic/core/components';
137

8+
import { PopoverController } from './popover-controller';
9+
1410
export const provideIonicAngular = (config?: IonicConfig): Provider[] => {
1511
/**
1612
* TODO FW-4967

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
import { Injector, Injectable, inject, EnvironmentInjector } from '@angular/core';
1+
import { Injector, inject, EnvironmentInjector } from '@angular/core';
2+
import { AngularDelegate, OverlayBaseController } from '@ionic/angular/common';
23
import type { PopoverOptions } from '@ionic/core/components';
34
import { popoverController } from '@ionic/core/components';
45

5-
import { OverlayBaseController } from '../utils/overlay';
6-
7-
import { AngularDelegate } from './angular-delegate';
8-
9-
@Injectable()
106
export class PopoverController extends OverlayBaseController<PopoverOptions, HTMLIonPopoverElement> {
117
private angularDelegate = inject(AngularDelegate);
128
private injector = inject(Injector);

0 commit comments

Comments
 (0)