ngx-intl-tel-input icon indicating copy to clipboard operation
ngx-intl-tel-input copied to clipboard

Autocomplete is coming on Country Search

Open fareed-glovision opened this issue 3 years ago • 4 comments

While selecting the country, when I search for the country on dialog its showing autocomplete. which is covering the country search list. is there any way to turn off autocomplete for search country field.

image

fareed-glovision avatar Sep 03 '20 05:09 fareed-glovision

Not at the moment, PR would be great for this.

pasevin avatar Oct 17 '20 16:10 pasevin

@pasevin try with this, it's worked for me.

  ngAfterViewChecked(): void {
    const getElement: ElementRef | any = document.querySelector(`ngx-intl-tel-input .search-container input`);
    if (getElement && !getElement.getAttribute('autocomplete')) {
      this.render.setAttribute(getElement, 'autocomplete', 'none');
      this.render.setAttribute(getElement, 'type', 'search');
    }
  }

Remember implement in your class component

export class YOUR_COMPONENT implements OnInit, AfterViewChecked <------------ *************

leifermendez avatar Dec 04 '20 13:12 leifermendez

+1 this would be a nice to have thing for cleaner UX

I tried @leifermendez 's solution, but I'm not sure who this.render is in this case

The solution that worked for me:

ngAfterViewChecked(): void {
  const input = document.getElementById('country-search-box');
  if (input) {
    input.setAttribute('autocomplete', 'off');
  }
}

victorbadila avatar Jun 22 '21 15:06 victorbadila

Still 2022 and I needed this so much. Previous workarounds didn't work for me, because i had multiple ngx-intl-tel-inputs in the same page. So i solved changing @leifermendez code like this:

 ngAfterViewChecked(): void {
    const elements: any = document.querySelectorAll(`ngx-intl-tel-input .search-container input#country-search-box`);
      elements.forEach(element => {
        if (element && !element.getAttribute('autocomplete')) {
          this.render.setAttribute(element, 'autocomplete', 'none');
          this.render.setAttribute(element, 'type', 'search');
        }
      });
  }

Btw this.render is from: constructor(private render: Renderer2)

rene-guerrero avatar May 30 '22 03:05 rene-guerrero