From e80f0b240968de0d642463e95a35adf8dbffd2e1 Mon Sep 17 00:00:00 2001 From: Andrzej Date: Thu, 18 May 2023 23:17:13 +0200 Subject: [PATCH] feat: return if the pop on NavController was successful (#27404) Issue number: Resolves #27403 --------- ## What is the current behavior? NavController.pop() returns `Promise`. ## What is the new behavior? NavController.pop() returns `Promise` propagating success/fail from underlying outlet. ## Does this introduce a breaking change? - [ ] Yes - [x] No --------- --- angular/src/providers/nav-controller.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/angular/src/providers/nav-controller.ts b/angular/src/providers/nav-controller.ts index 9fa391267f..101967f0f2 100644 --- a/angular/src/providers/nav-controller.ts +++ b/angular/src/providers/nav-controller.ts @@ -131,17 +131,21 @@ export class NavController { * * It recursively finds the top active `ion-router-outlet` and calls `pop()`. * This is the recommended way to go back when you are using `ion-router-outlet`. + * + * Resolves to `true` if it was able to pop. */ - async pop(): Promise { + async pop(): Promise { let outlet = this.topOutlet; while (outlet) { if (await outlet.pop()) { - break; + return true; } else { outlet = outlet.parentOutlet; } } + + return false; } /**