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

FEAT Customization of the input field (type, autocomplete) #124

Open
abasille opened this issue May 5, 2020 · 1 comment
Open

FEAT Customization of the input field (type, autocomplete) #124

abasille opened this issue May 5, 2020 · 1 comment

Comments

@abasille
Copy link

abasille commented May 5, 2020

Why?

  • The browser can autofill the input field with non-relevant suggestions (e.g. an address suggestion).

Peek 05-05-2020 17-00

Possible solutions

Sol#1 — Add props to set HTML attributes of the input field

  • autocomplete: with a random value, we could disable the browser autofill feature.
  • type: 'email', 'number' according to the HTML specs.
  • ...all other useful props

Sol#2 — Add a slot to override the default input field

Full-control for the developer.

Preferred solution

For me Sol#2 is the better choice. It brings freedom to the developer.

@JohMun I would like your opinion before coding a PR. Are you still maintain this package? Do you need some help?

@abasille
Copy link
Author

Sol#3 (partial solution)

Since v-bind="$attrs" is passed to the input component, attributes different than class, style, type or size can simply be passed to vue-tags-input:

<input
ref="newTagInput"
v-bind="$attrs"
:class="[createClasses(newTag, tags, validation, isDuplicate)]"
:placeholder="placeholder"
:value="newTag"
:maxlength="maxlength"
:disabled="disabled"
type="text"
size="1"
class="ti-new-tag-input"
@keydown="performAddTags(
filteredAutocompleteItems[selectedItem] || newTag, $event
)"
@paste="addTagsFromPaste"
@keydown.8="invokeDelete"
@keydown.9="performBlur"
@keydown.38="selectItem($event, 'before')"
@keydown.40="selectItem($event, 'after')"
@input="updateNewTag"
@blur="$emit('blur', $event)"
@focus="focused = true; $emit('focus', $event)"
@click="addOnlyFromAutocomplete ? false : selectedItem = null"
>

Example:

<vue-tags-input
  [...]
  :autocomplete="new Date().getTime()"
/>

will disable the browser autofill feature.

Drawbacks

The attribute type cannot be overriden.

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

No branches or pull requests

1 participant