question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: ion-back-button does not display if wrapped in custom component

See original GitHub issue

Bug Report Ionic version: [x] 4.0.0.rc-1

Current behavior: I do see in the element list that the second page in the stack gets an can-go-back class. However the ion-back-button remains invisible (display:none)

Expected behavior: ion-back-button should be visible. As there is a previous page in the stack.

Steps to reproduce: I have a page with a sidepanel menu. Which is a tab page. I navigate to the child page with navigateForward(), I can go back either by swiping back or pressing the tab icon.

Ionic info:

Ionic:

   ionic (Ionic CLI)             : 4.7.0 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.0.0-rc.1
   @angular-devkit/build-angular : 0.11.4
   @angular-devkit/schematics    : 7.2.1
   @angular/cli                  : 7.2.1
   @ionic/angular-toolkit        : 1.2.2

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : android 7.1.4, ios 4.5.5
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.3.1, (and 24 other plugins)

System:

   ios-deploy : 1.9.4
   NodeJS     : v11.6.0 (/usr/local/Cellar/node/11.6.0/bin/node)
   npm        : 6.5.0
   OS         : macOS Mojave
   Xcode      : Xcode 10.1 Build version 10O45e

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:18 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
bobajeffcommented, Nov 24, 2019

I ran into this issue following the tutorial on ionic’s youtube channel: “Ionic Framework Crash Course (4.0+)”.

Putting ion-back-button { display: block; } into detail.page.scss solved it. The video should be updated to include a note to this affect for people who come across it in the future.


Edit: also adding defaultHref='/home' to the ion-back-button attributes will also fix this. Edit2: also https://ionicframework.com/docs/api/buttons needs to be updated about this aswell.

5reactions
Silvest89commented, Jan 10, 2019

We can’t reproduce this issue, can you provide a repo case that reproduces the issue? If .can-go-back is there, what is preventing the ion-back-button to be visible?

Can you also share the markup of the page that is not getting the visible ion-back-button?

After further investigating I found out that it happens if you wrap the ion-header in another component. So that component actually contains the ion-header

So this won’t work

<header-component></header-component>
<ion-content><ion-content>

But if you take out the ion-header

<ion-header>
  <header-component></header-component>
</ion-header>
<ion-content></ion-content>

What I did found out is if you got back by swiping back you would get back to the root tab with a visible back button in the header.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ionic framework - Why is the ion-back-button not shown?
It is in my custom component app-header, which is in every single page. Thus in the home page and the detail page. I...
Read more >
Ion-back-button not showing and not working - Ionic Forum
Hello, All, I am facing an unknown issue in ionic5/capacitor/angular project. it's just that component doesn't show if defaultHref is empty.
Read more >
Ionic 5 UI Components Properties
Note that you are not limited to using core UI components only. If needed, a set of custom components can be created. More...
Read more >
Ionic Snippets
Fast templates with snippets of ~100 Ionic components ✓ Easy custom theming ... All code snippets are based on and follow the Ionic...
Read more >
ionic Archives
Ionic was initially built on top of the Apache Cordova framework, but the Ionic team ... These statistics data won't show us clear...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found