Ionic-framework: ion-searchbar cancel not visible if ion-toolbar has background color

Created on 7 Jan 2017  路  8Comments  路  Source: ionic-team/ionic-framework

Ionic version: (check one with "x")
[ ] 1.x
[x] 2.x

I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior:

ion-searchbar inside ion-toolbar is very less visible and cancel is not visible if ion-toolbar has background color

Expected behavior:

ion-searchbar should be clearly visible independent of ion-toolbar color

Steps to reproduce:

Related code:

 <ion-toolbar color='primary'>
    <ion-searchbar
      placeholder="Search here"
      [showCancelButton]="true"
      (ionInput)="onSearchInput($event)"
      (ionCancel)="onSearchCancel($event)">
    </ion-searchbar>
  </ion-toolbar>

Other information:

screenshot 2017-01-06 15 02 24

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

Your system information:

Cordova CLI: 6.4.0 
Ionic Framework Version: 2.0.0-rc.4
Ionic CLI Version: 2.1.18
Ionic App Lib Version: 2.1.9
Ionic App Scripts Version: 0.0.48
ios-deploy version: 1.9.0 
ios-sim version: 5.0.8 
OS: macOS Sierra
Node Version: v6.7.0
Xcode version: Xcode 8.1 Build version 8T61a

stale issue reply

Most helpful comment

I'm reopening this as I'd like to add a variable to make it easier to style the Cancel button for searchbar in iOS and override the variables.

All 8 comments

I just tested this and I see it just fine, using the defaults. I only changed the primary color to match the one you're using:

screenshot from 2017-01-07 13-30-48

You probably changed some other colors in your styles or the theme variables and that's causing this issue for you.

Hello everyone, thanks for opening an issue with us! @aggarwalankush have you added any custom css to the searchbar or toolbar? Also @jsayol , what does your template look like compared to the markup @aggarwalankush posted ?

Hey @jgw96, I just started a new blank project and then copied @aggarwalankush's markup into the Home page template's header.

Looks like this;

<ion-header>
  <ion-navbar color='primary'>
    <ion-title>
      Ionic Blank
    </ion-title>
  </ion-navbar>
  <ion-toolbar color='primary'>
    <ion-searchbar
      placeholder="Search here"
      [showCancelButton]="true"
      (ionInput)="onSearchInput($event)"
      (ionCancel)="onSearchCancel($event)">
    </ion-searchbar>
  </ion-toolbar>
</ion-header>

@jgw96 I found the problem.
<ion-toolbar color='primary'> works but I'm globally setting all toolbars color to primary using $toolbar-background: color($colors, primary); in variables.scss which causes this searchbar css issue. How can I globally change toolbar color to avoid this issue?

Steps to reproduce

  • Clone ionic-conference-app
  • Change
$toolbar-md-background:                   color($colors, primary);
$toolbar-md-active-color:                 #fff;

to

$toolbar-background:                   color($colors, primary);
$toolbar-active-color:                 #fff;
  • Searchbar is less visible and cancel is not visible at all

But if you add color='primary' to https://github.com/driftyco/ionic-conference-app/blob/master/src/pages/schedule/schedule.html#L23, it works like charm.

@aggarwalankush This could probably be easier to achieve, but the following variables will get the look you want for searchbar on iOS:

$toolbar-background:                           color($colors, primary);
$toolbar-active-color:                         #fff;

// This is a variable I made up to reuse for searchbar colors
$toolbar-contrast-color:                       color-contrast($colors, $toolbar-background);

// Override searchbar colors
$searchbar-ios-toolbar-input-background:       rgba($toolbar-contrast-color, .08);
$searchbar-ios-input-text-color:               $toolbar-contrast-color;
$searchbar-ios-input-placeholder-color:        rgba($toolbar-contrast-color, .5) !default;
$searchbar-ios-input-clear-icon-color:         rgba($toolbar-contrast-color, .5) !default;
$searchbar-ios-input-search-icon-color:        rgba($toolbar-contrast-color, .5) !default;

@brandyscarney Thanks for the info. It's easier to set <ion-toolbar color='primary'> which magically works perfectly than overriding so many variables manually. Also, I feel I shouldn't override many variables as ionic team always keep them in sync with official material or ios design specs. 馃憤

I'm reopening this as I'd like to add a variable to make it easier to style the Cancel button for searchbar in iOS and override the variables.

Thanks for the issue! This issue is being closed due to inactivity. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Thank you for using Ionic!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brandyscarney picture brandyscarney  路  3Comments

aslamj picture aslamj  路  3Comments

MrBokeh picture MrBokeh  路  3Comments

alan-agius4 picture alan-agius4  路  3Comments

SebastianGiro picture SebastianGiro  路  3Comments