# Ion-navbar back button and ion-title disappear after closing keyboard

**URL:** <https://forum.ionicframework.com/t/ion-navbar-back-button-and-ion-title-disappear-after-closing-keyboard/125499>\
**Category:** ionic-v3\
**Created:** [March 22, 2018, 9:52am UTC](https://forum.ionicframework.com/t/ion-navbar-back-button-and-ion-title-disappear-after-closing-keyboard/125499 "2018-03-22T09:52:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![choppedgarlic](https://avatars.discourse-cdn.com/v4/letter/c/ecccb3/32.png) [@choppedgarlic](https://forum.ionicframework.com/u/choppedgarlic)\
**Post date:** [March 22, 2018, 9:52am UTC](https://forum.ionicframework.com/t/ion-navbar-back-button-and-ion-title-disappear-after-closing-keyboard/125499/1 "2018-03-22T09:52:00Z")

</div>

In my app, I have a page as follows (abstracted):

```auto
<ion-header>
    <ion-navbar">
        <ion-title>Comments</ion-title>
    </ion-navbar>
</ion-header>

<ion-content>
    <card-comment-list
        [comments]="comments"
    ></comment-list>
</ion-content>

<ion-footer>
    <comment-input ></comment-input>
</ion-footer>

```

The comment input components is a form wrapped in a ion-toolbar. When I close the keyboard (native plugin keyboard) and there is a value in the textarea in the input, and there are comments, the back button and ion-title appear to disappear, though I can still click on the back button.

Submitting the form makes the back button and ion-title appear again.

Manually setting the styles and unsetting the styles again in Safari web inspector fixes the issue, so I suspect the DOM is not being updated. But I have no idea how to force it to update.

Screenshots

 ![IMG_0360](https://global.discourse-cdn.com/ionicframework/original/3X/3/1/310335ac48a252b771ceebf4d49ebdc6e4e5bbfa.jpg)

Header shows up fine if there is a value in the textarea but are no comments after closing keyboard

 ![IMG_0361](https://global.discourse-cdn.com/ionicframework/original/3X/d/8/d84acf60c7b6d515bc7e9b5c0f0f65884c3f7ce0.jpg)

Header disappears if there is a value in the textarea and there are comments… I have no idea why, I’m displaying comments in an ion-list

EDIT: I’m using iOS.

---

<div class="post-metadata">

**Author:** ![choppedgarlic](https://avatars.discourse-cdn.com/v4/letter/c/ecccb3/32.png) [@choppedgarlic](https://forum.ionicframework.com/u/choppedgarlic)\
**Post date:** [March 22, 2018, 10:46am UTC](https://forum.ionicframework.com/t/ion-navbar-back-button-and-ion-title-disappear-after-closing-keyboard/125499/2 "2018-03-22T10:46:17Z")

</div>

Somehow managed to figure out a workaround… Don’t ask me how it works, lol…

Page code

```auto
<ion-header>
    <ion-navbar [navbar-fix]="content">
        <ion-title>Comments</ion-title>
    </ion-navbar>
</ion-header>

<ion-content #content>
    <card-comment-list
        [comments]="comments"
    ></comment-list>
</ion-content>

<ion-footer>
    <comment-input ></comment-input>
</ion-footer>

```

Navbar-fix directive

```auto
import { Directive, ElementRef, Input, NgZone } from '@angular/core';
import { Keyboard } from '@ionic-native/keyboard';
import { Content, Platform } from 'ionic-angular';
import { Subscription } from 'rxjs/Subscription';

/**
 * @description
 * The 'navbar-fix' directive fixes the bug where back button and title disappears
 * when the keyboard is closed and there is an input that has a value
 */

@Directive({
  selector: '[navbar-fix]'
})
export class NavbarFix {
  @Input('navbar-fix') content: Content;

  private paddingTop:string = "0px";

  private onShowSubscription: Subscription;
  private onHideSubscription: Subscription;

  constructor (
    private elementRef: ElementRef,
    private keyboard: Keyboard,
    private platform: Platform,
    private zone: NgZone
  ) {}

    ngOnInit() {
        if (this.platform.is('cordova') && this.platform.is('ios')) {
            this.onShowSubscription = this.keyboard.onKeyboardShow()
            .subscribe(e => this.onShow());

            this.onHideSubscription = this.keyboard.onKeyboardHide()
            .subscribe(() => this.onHide());
        }
    }

    ngOnDestroy() {
        if (this.onShowSubscription) {
            this.onShowSubscription.unsubscribe();
        }
        if (this.onHideSubscription) {
            this.onHideSubscription.unsubscribe();
        }
    }

    private onShow() {
        this.elementRef.nativeElement.style.backgroundColor = "#fff";
    }

    private onHide() {
        this.elementRef.nativeElement.style.backgroundColor = "#000";
    }

}

```

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:44pm UTC](https://forum.ionicframework.com/t/ion-navbar-back-button-and-ion-title-disappear-after-closing-keyboard/125499/3 "2021-07-19T21:44:11Z")

</div>

Closed on July 19, 2021, 9:44pm UTC


