Ionic 4 Tabs TypeError: Cannot read property 'querySelectorAll' of null at getBackButton

I’m getting this Error when using Child Routes and Tabs.

TypeError: Cannot read property 'querySelectorAll' of null at getBackButton

starting from here will open the first child route to another info page
detail.page.html

<ion-item button lines="none" [routerLink]="['details']">More</ion-item>

detail-routing.module.ts

const routes: Routes = [
    {
        path: '',
        component:DetailPage,
        children: [
            {
                path: '',
                redirectTo: 'details',
                component: DetailInfosPage
            }
        ]
    }
];

detail-infos.page.html

<ion-header>
    <ion-toolbar>
        <ion-buttons slot="start">
            <ion-back-button color="secondary"></ion-back-button>
        </ion-buttons>
        <ion-title>Extra Infos</ion-title>
    </ion-toolbar>
</ion-header>
<ion-content>
    <ion-tabs>
        <ion-tab-bar slot="top">
            <ion-tab-button tab="tab1">
                <ion-label>Infos</ion-label>
            </ion-tab-button>

            <ion-tab-button tab="tab2">
                <ion-label>Infos 2</ion-label>
                <ion-badge>6</ion-badge>
            </ion-tab-button>
        </ion-tab-bar>
    </ion-tabs>
</ion-content>

detail-infos-routing.module.ts

const routes: Routes = [
    {
        path: 'details',
        component: DetailInfosPage,
        children: [
            {
                path: 'tab1',
                children: [
                    {
                        path: '',
                        loadChildren: () => import('../tab1/tab1.module').then(m => m.Tab1PageModule)
                    }
                ]
            },
            {
                path: 'tab2',
                children: [
                    {
                        path: '',
                        loadChildren: () => import('../tab2/tab2.module').then(m => m.Tab2PageModule)
                    }
                ]
            },
            {
                path: '',
                redirectTo: 'details/tab1',
                pathMatch: 'full'
            }
        ]
    }
];

After clicking

<ion-item button lines="none" [routerLink]="['details']">More</ion-item>

the Error is thrown, but child page with Tabs is loaded but none of the Tabs is active

So what do i’m missing here?

Please post package.json.

package.json

{
    "name": "app",
    "version": "0.0.1",
    "author": "",
    "description": "",
    "homepage": "",
    "scripts": {
        "ng": "ng",
        "start": "ng serve",
        "build": "ng build",
        "test": "ng test",
        "lint": "ng lint",
        "e2e": "ng e2e"
    },
    "private": true,
    "dependencies": {
        "@angular/common": "^8.2.14",
        "@angular/core": "^8.2.14",
        "@angular/forms": "^8.2.14",
        "@angular/platform-browser": "^8.2.14",
        "@angular/platform-browser-dynamic": "^8.2.14",
        "@angular/router": "^8.2.14",
        "@ionic-native/android-permissions": "^5.21.6",
        "@ionic-native/core": "^5.22.0-beta-1",
        "@ionic-native/diagnostic": "^5.21.6",
        "@ionic-native/geolocation": "^5.21.6",
        "@ionic-native/google-maps": "^5.5.0",
        "@ionic-native/location-accuracy": "^5.21.6",
        "@ionic-native/native-geocoder": "^5.21.6",
        "@ionic-native/native-storage": "^5.21.6",
        "@ionic-native/splash-screen": "^5.21.6",
        "@ionic-native/status-bar": "^5.21.6",
        "@ionic/angular": "^5.0.2",
        "cordova-android": "^8.1.0",
        "cordova-browser": "^6.0.0",
        "cordova-ios": "^5.1.1",
        "cordova-plugin-add-swift-support": "^2.0.2",
        "cordova-plugin-android-permissions": "^1.0.2",
        "cordova-plugin-geolocation": "^4.0.2",
        "cordova-plugin-googlemaps": "git+https://github.com/mapsplugin/cordova-plugin-googlemaps.git#multiple_maps",
        "cordova-plugin-nativegeocoder": "^3.2.2",
        "cordova-plugin-nativestorage": "^2.3.2",
        "cordova-plugin-request-location-accuracy": "^2.3.0",
        "cordova.plugins.diagnostic": "^5.0.1",
        "core-js": "^3.6.4",
        "rxjs": "^6.5.4",
        "tslib": "^1.11.0",
        "zone.js": "^0.10.2"
    },
    "devDependencies": {
        "@angular-devkit/architect": "^0.803.23",
        "@angular-devkit/build-angular": "^0.803.23",
        "@angular-devkit/core": "^8.3.23",
        "@angular-devkit/schematics": "^8.3.23",
        "@angular/cli": "^8.3.23",
        "@angular/compiler": "^8.2.14",
        "@angular/compiler-cli": "^8.2.14",
        "@angular/language-service": "^8.2.14",
        "@ionic/angular-toolkit": "^2.2.0",
        "@types/jasmine": "^3.5.7",
        "@types/jasminewd2": "~2.0.3",
        "@types/node": "^13.7.6",
        "codelyzer": "^5.2.1",
        "cordova-plugin-device": "^2.0.3",
        "cordova-plugin-ionic-keyboard": "^2.2.0",
        "cordova-plugin-ionic-webview": "^4.1.3",
        "cordova-plugin-splashscreen": "^5.0.3",
        "cordova-plugin-statusbar": "^2.4.3",
        "cordova-plugin-whitelist": "^1.3.4",
        "ionicons": "^5.0.0",
        "jasmine-core": "^3.5.0",
        "jasmine-spec-reporter": "~4.2.1",
        "karma": "^4.4.1",
        "karma-chrome-launcher": "^3.1.0",
        "karma-coverage-istanbul-reporter": "^2.1.1",
        "karma-jasmine": "^3.1.0",
        "karma-jasmine-html-reporter": "^1.5.2",
        "protractor": "^5.4.3",
        "ts-node": "^8.6.2",
        "tslint": "^6.0.0",
        "typescript": "3.4.5"
    },
    "cordova": {
        "plugins": {
            "cordova-plugin-whitelist": {},
            "cordova-plugin-statusbar": {},
            "cordova-plugin-device": {},
            "cordova-plugin-splashscreen": {},
            "cordova-plugin-ionic-webview": {
                "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
            },
            "cordova-plugin-ionic-keyboard": {},
            "cordova-plugin-geolocation": {},
            "cordova-plugin-nativestorage": {},
            "cordova-plugin-android-permissions": {},
            "cordova-plugin-nativegeocoder": {
                "LOCATION_WHEN_IN_USE_DESCRIPTION": "Use geocoder service"
            },
            "cordova-plugin-request-location-accuracy": {
                "PLAY_SERVICES_LOCATION_VERSION": "16.+"
            },
            "cordova.plugins.diagnostic": {
                "ANDROID_SUPPORT_VERSION": "28.+"
            },
            "cordova-plugin-googlemaps": {}
        },
        "platforms": [
            "ios",
            "android",
            "browser"
        ]
    }
}

What version do you actually have? I wonder if you are being impacted one way or another by this commit that happened between 5.0.2 and 5.0.3.

right now it is Version 5.0.2
taken from node_modules/@ionic/angular/package.json

"_from": "@ionic/angular@5.0.2",
  "_id": "@ionic/angular@5.0.2",

I guess I misread GitHub’s tags, because that commit is listed in the release notes for 5.0.2. Can we try going the other direction? Cap to 5.0.1, run npm i. Perhaps you’ve discovered a regression.

1 Like

Yes, that’s it! Thanks @rapropos.
Downgrading to 5.0.1 solves the Problem

1 Like

Thanks for reporting back. I commented on the commit suggesting it may have caused a regression - if you would like to open an issue about it, maybe it would get more attention.

That’s a good idea. Will file a bug report

Hello all, I’m facing the same issue and it was fixed downgrading to 5.0.1. Thanks by the solution.

@magic-77 Could you please share the bug report you opened? I would like to follow up that in order to know when it gets fixed.

Thank you very much.

Hi, the Issue is fixed with Version 5.0.4. Just update. It works for me now

1 Like

@magic-77 @rapropos I still have the issue in 5.0.5. Do you have the link for the bug report, so I can put more details there?

This issue only happens from navigating from Login Page to Tabs Page with it’s children.

I can see the problem in the tabs bar buttons. Some of them are only loading depending of an observable value, tied with ngIf.

<ion-tab-button
                *ngIf="userRoleCategory && ( (userRoleCategory === userRolesCategories.Manager) ||
            (userRoleCategory === userRolesCategories.Engineer))"
                tab="tasks"
            >

Here is my package.json.

"dependencies": {
        "@angular/animations": "^9.0.6",
        "@angular/common": "^9.0.6",
        "@angular/core": "^9.0.6",
        "@angular/forms": "^9.0.6",
        "@angular/platform-browser": "^9.0.6",
        "@angular/platform-browser-dynamic": "^9.0.6",
        "@angular/router": "^9.0.6",
        "@capacitor/android": "^1.5.1",
        "@capacitor/core": "^1.5.1",
        "@capacitor/ios": "^1.5.1",
        "@ionic-native/core": "^5.22.0",
        "@ionic-native/splash-screen": "^5.22.0",
        "@ionic-native/status-bar": "^5.22.0",
        "@ionic/angular": "^5.0.5",
        "@ngrx/effects": "^9.0.0",
        "@ngrx/entity": "^9.0.0",
        "@ngrx/router-store": "^9.0.0",
        "@ngrx/store": "^9.0.0",
        "chart.js": "^2.9.3",
        "core-js": "^3.6.4",
        "crypto-js": "^4.0.0",
        "immer": "^6.0.1",
        "rxjs": "~6.5.1",
        "tslib": "^1.10.0",
        "uuid": "^7.0.2",
        "zone.js": "~0.10.2"
    },
    "devDependencies": {
        "@angular-devkit/architect": "^0.900.6",
        "@angular-devkit/build-angular": "^0.900.6",
        "@angular-devkit/core": "^9.0.6",
        "@angular-devkit/schematics": "^9.0.6",
        "@angular/cli": "^9.0.6",
        "@angular/compiler": "^9.0.6",
        "@angular/compiler-cli": "^9.0.6",
        "@angular/language-service": "^9.0.6",
        "@capacitor/cli": "^1.5.1",
        "@ionic/angular-toolkit": "^2.2.0",
        "@ngrx/store-devtools": "^9.0.0",
        "@types/crypto-js": "^3.1.43",
        "@types/jasmine": "^3.5.9",
        "@types/jasminewd2": "~2.0.3",
        "@types/node": "^13.9.1",
        "codelyzer": "^5.1.2",
        "eslint": "^6.8.0",
        "jasmine-core": "^3.5.0",
        "jasmine-spec-reporter": "~4.2.1",
        "karma": "^4.4.1",
        "karma-chrome-launcher": "^3.1.0",
        "karma-coverage-istanbul-reporter": "^2.1.1",
        "karma-jasmine": "^3.1.1",
        "karma-jasmine-html-reporter": "^1.5.2",
        "protractor": "^5.4.3",
        "ts-node": "^8.6.2",
        "tslint": "^5.0.0",
        "typescript": "~3.7.5"
    }

In Android it works fine but in iOS, the screen freezes at this point and I receive the error:

ion-app_8-ios.entry.js:716 TypeError: Cannot read property 'querySelectorAll' of null
    at getBackButton (ios.transition-b4752795.js:29)
    at createLargeTitleTransition (ios.transition-b4752795.js:47)
    at iosTransitionAnimation (ios.transition-b4752795.js:245)
    at animation (index-1469ea79.js:67)

Thank you very much.
BR,
Daniel.

Hi Daniel, did you tried to setup Buttons statically (without ngIf) and then test Routing?
For me i didn’t send an Bugreport as the Bugfixed Version was published very quick

Hi magic-77. Sorry about the late response.

I found the issue. I was managing a routing redirect inside the parent tab page that was causing the issue in iOS. In Android it works ok but not in iOS.

I fixed it taking care of routing redirect decisions before entering in the page, from login effect (using NgRx). With that the problem is fixed.

I hope this information can help anyone else in the same situation.

Thank you very much by your attention.
BR,
Daniel.