shentao / vue-multiselect

Universal select/multiselect/tagging component for Vue.js
https://vue-multiselect.js.org/
MIT License
6.73k stars 992 forks source link

[Feature Request] Define max length of a new tag #1077

Open spotman opened 5 years ago

spotman commented 5 years ago

Hi there!

Thanks again for this awesome library!

The case: new tag length must not exceed 50 chars. Possible fix: set maxlength on the input field.

RTFM already but still can not find a way to do it out-of-the-box. Is it possible to define new tag max length or prevent typing in search-change event?

Cheers, Denis.

brandonburkett commented 4 years ago

Hey @spotman did you implement a workaround for this?

spotman commented 4 years ago

@brandonburkett Sorry, no. There is no way to control this behavior outside of the library, the only possible workaround is to fork-and-patch.

brandonburkett commented 4 years ago

@spotman Here is my hack workaround for now (can be used in mounted or after multiselect is rendered)

await this.$nextTick();

const selectInput = document.querySelector('.multiselect__input')

if (selectInput) {
    selectInput.setAttribute('maxlength', '50');
}
spotman commented 4 years ago

Thanks for sharing, @brandonburkett !