After overriding back button behaviour popovers dont close on hardware back button press

I have changed hardware back button behaviour , so now opened popovers dont close.

I have 4 tabs. One of the tabs has a popover.

Hardware backbutton behaviour is changed in tabs.ts (where all tabs are defined).

Now , how do I close any opened popover (which resides in one of the tab component) from tabs.ts ?

Did you find the solution to this. I have the same issue. Please post the solution.

I posted my workaround here ! https://github.com/driftyco/ionic/issues/10549

In your popover.ts , override back button and only dismiss popover

platform.registerBackButtonAction(() => {
          this.viewCtrl.dismiss();
    });

On popover dismiss , override it again back to original config ( this is specific to my requirement )

popover.onDidDismiss((data) => {
      this.platform.registerBackButtonAction(() => {
        this.tabs = this.navCtrl.parent;
        let tabNav = this.tabs.getActiveChildNav();
        if (this.navCtrl.canGoBack()) {
          // this.navCtrl.pop();
          console.log(this.navCtrl.getActive());
          this.navCtrl.removeView(this.navCtrl.getActive()).then((res) => {
            console.log(res);
          }).catch((err) => {
            console.log(err);
          });
        } else {
          if (tabNav['_views'].length > 1) {
            // this.tabs.viewCtrl['_nav'].pop();
            console.log(this.tabs.viewCtrl['_nav'].getActive());
            this.tabs.viewCtrl['_nav'].removeView(this.tabs.viewCtrl['_nav'].getActive()).then((res) => {
              console.log(res);
            }).catch((err) => {
              console.log(err);
            });
          } else if (tabNav['_views'].length == 1) {
            this.platform.exitApp();
          }
        }
      });

});

:slight_smile: :+1:

1 Like