Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow disabling of browser autocomplete #269

Closed
arun-maddheshia opened this issue Feb 16, 2018 · 35 comments · Fixed by #900
Closed

Allow disabling of browser autocomplete #269

arun-maddheshia opened this issue Feb 16, 2018 · 35 comments · Fixed by #900
Assignees

Comments

@arun-maddheshia
Copy link

Please fill below information if issuing a bug report.

Expected behaviour

Set the autocomplete attribute of the input field to "off", or allow passing it as an optional attribute so the search would work better.

Actual behaviour

right now the search results has double dropdown. One by the browser autocomplete, and one by the ng-select. looks wierd.

ss

More Info

ng-select version: latest

browser: Chrome
reproducible in demo page: Yes

@varnastadeus
Copy link
Member

@arun-maddheshia I think it should be disabled by default. Will fix it.

@arun-maddheshia
Copy link
Author

@varnastadeus thanx 👍 when it get it release :)

@varnastadeus
Copy link
Member

@arun-maddheshia later today

@arun-maddheshia
Copy link
Author

@varnastadeus autocomplete off is not working in chrome :(
screenshot_2018-02-18_16-28-07

@varnastadeus
Copy link
Member

As it seems chrome ignores autocomplete off, but if you provide any semantic value then it will work. Not sure about other browsers though

@arun-maddheshia
Copy link
Author

@varnastadeus so what workaround to do with ng select because if user autofills the search field its get broken. User unable to select the ng-select dropdown values.

@dan-andreoli
Copy link

@varnastadeus with the last chrome update (v64.x) the workaround not working anymore, but I've noticed that the autocomplete doesn't break the select, but it only hide the selected value. Here a simple solution: ass to the css class .ng-select { z-index: -1; } and this solves the hiding problem.

@arun-maddheshia
Copy link
Author

@varnastadeus any update on it, the issue is still exist.
@dan-andreoli .ng-select { z-index: -1; } is not solved the problem.

@varnastadeus
Copy link
Member

@arun-maddheshia please provide reproducible plnkr, I tried to reproduce it with no luck.

@arun-maddheshia
Copy link
Author

@varnastadeus Just create a StackBlitz

screenshot_2018-03-11_22-55-55

@varnastadeus
Copy link
Member

@arun-maddheshia thanks, will look at it

@varnastadeus varnastadeus reopened this Mar 12, 2018
@pwarelis
Copy link

To disable (fool) the autofill you need to set the input name attribute to something that chrome has not seen before and has no history of. Try uuid.

@anjmao
Copy link
Member

anjmao commented Apr 10, 2018

As 30201c0 is merged now we have newId function which can be used on input name.

@arun-maddheshia
Copy link
Author

@anjmao can we fix it please :)

@anjmao
Copy link
Member

anjmao commented Apr 19, 2018

@arun-maddheshia have you looked at https://stackoverflow.com/questions/12374442/chrome-browser-ignoring-autocomplete-off? Setting <form autocomplete="off"> should solve this problem for you :)

@arun-maddheshia
Copy link
Author

@anjmao I tried all these things but nothing works, only solution is #269 (comment) autocomplete="radomvalues". So if you make autocomplete="{{ dropdownId }}" it working fine I tested with it.

@dottodot
Copy link

The other option is to use

  <input #filterInput  *ngIf="searchable" type="search">

@varnastadeus
Copy link
Member

@arun-maddheshia I have added id as autocomplete value.

@przemkow
Copy link

@varnastadeus, unfortunately, it does not solve the problem. Chrome autofill still pops up on my browser.

Chrome: Version 67.0.3396.87 (Official Build) (64-bit)
ng-select: 1.5.2

@unit147
Copy link

unit147 commented Aug 29, 2018

Chrome: Version 68.0.3440.106 (Official Build) (64-bit)
ng-select: 2.5.1 is not usable because of this bug :(

@DonJuwe
Copy link

DonJuwe commented Sep 18, 2018

@varnastadeus, if I change it to autocomplete="off" manually in Chrome Version 69.0.3497.100 (64-Bit) it works. Could you please change it?

@varnastadeus
Copy link
Member

instead of saying it doesn't work, create reproducible example proving it

@vmanchev
Copy link

vmanchev commented Oct 6, 2018

What I found for this bug and Chrome is that the labelForId is problematic.

  • if labelForId is not used, the problem does not exists. You'll lose some usability though, as when you click on the form label, the ng-select control will not be focused.
  • if labelForId is used with some common name (like "client" in my case), Chrome will do its best to provide browser autocomplete.
  • if labelForId is used with unique value (e.g. "client123"), there will be no browser autocomplete

jakemdunn pushed a commit to jakemdunn/ng-select that referenced this issue Oct 16, 2018
jakemdunn pushed a commit to jakemdunn/ng-select that referenced this issue Oct 16, 2018
@DonJuwe
Copy link

DonJuwe commented Oct 24, 2018

As @vmanchev mentioned, labelForId seems to be the problem since it is being converted to a property id of the generated <input>. Here is a StackBlitz using the current version (2.11.1) where you can reproduce the issue when you have values stored in your browser for an <input> with property id="city" (if this does not work try using keywords like email or name).
This triggers the browser's autocomplete like here:
2018-10-24 16_54_48-ng-select - stackblitz
By manually changing autocomplete to off for the generated <input> Chrome's autocomplete will not be triggered.

@Lars-Wunderlich
Copy link

Urgently needed and helpful....

@smasala
Copy link

smasala commented Oct 25, 2018

@DonJuwe workaround:

ngOnInit() {
      setTimeout( () => {
        document.querySelector('ng-select input[autocomplete]').setAttribute('autocomplete', 'off');
      });
}

@Xyaren
Copy link

Xyaren commented Oct 25, 2018

@varnastadeus This should be reopened as the bug still exists, as prooven in the example provided by @DonJuwe

@varnastadeus varnastadeus reopened this Oct 25, 2018
@varnastadeus
Copy link
Member

Ok I have it reproducible so I will check it out. I will try to see if autocomple="off" works while labelForId is applied

@esoyke
Copy link

esoyke commented Mar 13, 2019

@smasala I used a similar approach but instead set the autocomplete value to something nonsensical ('foobar'), as it seems autocomplete=off was being ignored by Chrome now.

NickMele pushed a commit to NickMele/ng-select that referenced this issue Apr 12, 2019
@bharatlagad
Copy link

@varnastadeus... Have you updated autocomplete = "off" on npm

@sarnecki-cic
Copy link

My workaround was to change input id in ngAfterViewInit() and adding timpestamp there:

ngAfterViewInit(): void {
        document.querySelector('input[data-name=ng-select]').id = 'newId-' + this.timestamp;
    }

@Ogunk
Copy link

Ogunk commented Oct 21, 2020

@varnastadeus Hi, I'm still having this issue and tried everything here and other places but nothing is working.

Here is my code :

      <label for="ppp">Organization</label>
      <ng-select [hideSelected]="true" autocomplete="off" placeholder="Select an organization" labelForId="ppp"
        [closeOnSelect]="true" [searchable]="true" formControlName="organizationId">
        <ng-option *ngFor="let organization of availableOrganizations" [value]="organization.id">
          {{ organization.name }}
        </ng-option>
      </ng-select>

image

The weird thing is if I delete the "for" in the label and the "labelForId" it is working, or I if delete one of the two or if one is not matching the other.

Anyone have an idea of why is that ?

ng-select version : 4.0.4
Browser : Chrome

@huynv86
Copy link

huynv86 commented Oct 22, 2021

it doesn't work, please fix this bug soon

@earshinov
Copy link

@huynv86 , it still works fine for us (ng-select 7.0.1). Which ng-select version are you using? Do you have a repro?

@jongomes
Copy link

jongomes commented Apr 8, 2022

< nz-select formControlName="gateway" nzShowSearch nzAllowClear nzPlaceHolder="pick the gateway" >

work me, nzPlaceHolder

"ng-zorro-antd": "^13.1.0",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.