Ng-zorro-antd: nzShowSearch on nz-select does not work in IOS 13

Created on 15 Oct 2019  ·  24Comments  ·  Source: NG-ZORRO/ng-zorro-antd

Reproduction link

https://ng-zorro-antd-start-bbhuis.stackblitz.io

Steps to reproduce

Implemented Attribute:
nzShowSearch

What is expected?

Input should be focused and keyboard should appear

What is actually happening?

Keyboard does not appear

| Environment | Info |
|---|---|
| ng-zorro-antd | 8.4.0 |
| Browser | IOS 13 | IPhone 6< |


similar to : https://github.com/NG-ZORRO/ng-zorro-antd/issues/1653

mobile Select

Most helpful comment

Managed to fix it with a workaround!

I drew inspiration for fixing this issue from here and did the following:

In the component.less:

::ng-deep nz-select div.ant-select-search.ant-select-search--inline {
  display: block !important;
}

Alternatively, you could add it site-wide in styles.less after the styles for antd:

nz-select div.ant-select-search.ant-select-search--inline {
  display: block !important;
}

Unfortunately the !important must remain because the display style is dynamically applied ([style.display]="searchDisplay") and therefore applies after CSS applies.

Until an official fix, I hope this workaround can help someone else who's stuck pulling their hair out over this.

All 24 comments

the examples on the official website are also not working...
any solution to this?

@WeslleyDeSouza The same problem here with ios 12. I also face the #4259 when use nz-select as a search box.

And then, I've made a custom search box by nz-autocomplete like this https://stackblitz.com/edit/angular-pyvfwe to resolve those issues

It is working fine for now, at least it is useful when we wait for an official support to this.

@aaaahoang123 Thanks for ur reply..

note:
If I remove the css class of the parent input element, the keyboard trigger starts to work again..

any update on this?

Hello,
any updates on this? It's serious problem for us.
Is there any chance this issue will be resolved in next version?
Thanks for any reply.

yes in the mean while im using select2,
till this is fixed..

Thanks for your advice!
I've already known about select2 ... but because it needs jQuery, it's implementation would be our really really worst case scenario...
And based on their documentation, select2 doesn't cover all features we are currently using with nz-select :(

which feautures do you need that select2 doesn't have?

there is also an npm version of select2 but its also an jQuery wrapper

Actually, there's a lot, eg. custom compareWith function, simple ability to clear selected option, ability to pass custom template when no remote data found, etc. ...

And I assume there's no output callbacks like nzOpenChange, nzScrollToBottom, nzOnSearch available in it's Angular wrapper.

And at least there's design... it looks different (worse) than nz-select and it feels like it would't be zero-time job to make it look similar to nz-select (and rest of ng-zorro components, we're using)...

So if is there any way to speed up this bug fixation, I'm all ears.

Is there any chance this issue will be resolved in next version?

@vthinkxie could you please provide us any information/updates about this?

@junekpavel
could you create a new ticked?

@aaaahoang123 Thanks for ur reply..

note:
If I remove the css class of the parent input element, the keyboard trigger starts to work again..


  • any update on this?

@WeslleyDeSouza is there any way you can list the exact class you removed to get the keyboard working again on IOS?

Managed to fix it with a workaround!

I drew inspiration for fixing this issue from here and did the following:

In the component.less:

::ng-deep nz-select div.ant-select-search.ant-select-search--inline {
  display: block !important;
}

Alternatively, you could add it site-wide in styles.less after the styles for antd:

nz-select div.ant-select-search.ant-select-search--inline {
  display: block !important;
}

Unfortunately the !important must remain because the display style is dynamically applied ([style.display]="searchDisplay") and therefore applies after CSS applies.

Until an official fix, I hope this workaround can help someone else who's stuck pulling their hair out over this.

I found that long press will pop up the keyboard.

Managed to fix it with a workaround!

I drew inspiration for fixing this issue from here and did the following:

In the component.less:

::ng-deep nz-select div.ant-select-search.ant-select-search--inline {
  display: block !important;
}

Alternatively, you could add it site-wide in styles.less after the styles for antd:

nz-select div.ant-select-search.ant-select-search--inline {
  display: block !important;
}

Unfortunately the !important must remain because the display style is dynamically applied ([style.display]="searchDisplay") and therefore applies after CSS applies.

Until an official fix, I hope this workaround can help someone else who's stuck pulling their hair out over this.

Can confirm this workaround works

Any update on an official fix for this issue on iOS as we are experiencing this as well?

This is also a major blocker for me. Hopefully it gets fixed soon.

There is a tiny gap between the beginning of the select and before the placeholder that actually triggers the input and thus the keyboard.

Workaround dont work in 9.0.0

I figure out a workaround, I simply remove "readonly" attribute in nz-select input element to fix this issue.

const inputEle = this.renderer.selectRootElement('nz-select nz-select-search input');
this.renderer.removeAttribute(inputEle , 'readonly');

I figure out a workaround, I simply remove "readonly" attribute in nz-select input element to fix this issue.

const inputEle = this.renderer.selectRootElement('nz-select nz-select-search input');
this.renderer.removeAttribute(inputEle , 'readonly');

This workaround works

 ngAfterViewInit(): void {
    setTimeout(() => {
      const allEles: any = document.querySelectorAll('nz-select nz-select-top-control nz-select-search input');
      for (const ele of allEles) {
        this.renderer.removeAttribute(ele, 'readonly');
      }
    }, 1500);

  }

  onBlur() {
    console.log('blur triggered');
    setTimeout(() => {
      const allEles: any = document.querySelectorAll('nz-select nz-select-top-control nz-select-search input');
      for (const ele of allEles) {
        this.renderer.removeAttribute(ele, 'readonly');
      }
    }, 500);
  }
<form>
.....
<nz-form-item>
<nz-form-control>
        <nz-select
          nzShowSearch
          formControlName="test1"
          (nzBlur)="onBlur()"
        >
....
</nz-select>
<nz-form-control>
</nz-form-item>

<nz-form-item>
<nz-form-control>
        <nz-select
          nzShowSearch
          formControlName="test2"
          (nzBlur)="onBlur()"
        >
....
</nz-select>
<nz-form-control>
</nz-form-item>
......
</form>

| Environment | Info |
| :---: | :---: |
ng-zorro-antd | 9.3.0 |
Browser | iOS 13.5.1 |

fix this, please. It happening on all mobile devices, on android too.

Maybe the same problem with #5645.

Was this page helpful?
0 / 5 - 0 ratings