Page 1 of 1

p-autocomplete rendered autocomplete="off" on input element no longer works in Chrome

Posted: 13 Jun 2019, 00:36
by aflorin
p-autocomplete renders autocomplete=off in the input elementRef in order to prevent chrome's cached autocomplete values from overlaying p-autocomplete's list box. However, chrome no longer honors that value. The current technique is to set autocomplete="no" ("no" being an unrecognized value by Chrome so it doesn't try to fill the input with stored values).

I initially tried using:

@ViewChild(AutoComplete) myAutoComplete: AutoComplete;

ngAfterViewInit() {
this.renderer.setElementAttribute(
this.myAutoComplete.inputEL.nativeElement,
"autocomplete",
"no");
}

Unfortunately, for some reason inputEL was undefined even though myAutoComplete was being rendered

I wound up having to fix it by manually modifying node_modules\primeng\components\autocomplete.metadata.json and setting autocomplete=\"off\" to autocomplete=\"no\"

I suggest the above be implemented in the next version of primeng to keep-up with Chrome's current behavior.