pstanoev / simple-svelte-autocomplete

Simple Autocomplete / typeahead component for Svelte
http://simple-svelte-autocomplete.surge.sh/
MIT License
468 stars 79 forks source link

set google autocomplete off #153

Closed AdrianNigro closed 2 years ago

AdrianNigro commented 2 years ago

the problem: It seems that chrome doesn't respect the autocomplete = 'off' attribute

our workarround: in our project we are assigning to the autocomplete attribute the value "none" so that it works well in chrome

the improvement in the component: to make this component work we were forced to download it and modify it to get the desired attributes.

Our solution was to add this line to the input declaration:

{...$$restProps}

and the code is like this:

    <input
      type="text"
      class="{inputClassName ? inputClassName : ''} {noInputStyles
        ? ''
        : 'input autocomplete-input'}"
      id={inputId ? inputId : ""}
      autocomplete={html5autocomplete ? "on" : "off"}
      {placeholder}
      {name}
      {disabled}
      {required}
      {title}
      readonly={readonly || (lock && selectedItem)}
      {tabindex}
      bind:this={input}
      bind:value={text}
      on:input={onInput}
      on:focus={onFocusInternal}
      on:blur={onBlurInternal}
      on:keydown={onKeyDown}
      on:click={onInputClick}
      on:keypress={onKeyPress}
      {...$$restProps}
    />

Please, consider adding this line of code to expose any other attribute that it wants to modify from the outside without having to modify the component code.

pstanoev commented 2 years ago

Added suggested $$restProps but also value to controll the off value autocompleteOffValue

Version 2.4.2.
AdrianNigro commented 2 years ago

Great thanks!