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

Input/Placeholder should be hidden if maxTags is greater than tags length #115

Open
danbrellis opened this issue Dec 19, 2019 · 2 comments

Comments

@danbrellis
Copy link

It seems to me that once the tags length is equal to the maxTags prop, the input should no longer be shown. It gives the user the false sense that they can continue to add more tags since the placeholder is shown and they can type into the field.

I saw this issue resolved about hiding the placeholder, but it doesn't address the user's ability to type a new tag: #21

It seems like a simple fix by just adding the below v-show on the input tag in vue-tags-input.vue.

v-show="maxTags > tags.length"

I can create a pull request.

@danbrellis
Copy link
Author

PR added: #116

@abasille
Copy link

abasille commented May 5, 2020

Hi @danbrellis ,

By hiding the input field when maxTags is reached, you disallow to react when the end-user is trying to add a new tag:

  watch: {
    // Listen to the input field
    query: 'refreshSuggestions',
  },
  methods: {
    async refreshSuggestions() {
      if (this.maxTags > 0 && this.tags.length >= this.maxTags) {
        // *** With #116 , the following code will never be executed
        // Delete the input field
        this.query = '';
        // Display a warning message to the end-user in the suggestion list
        this.suggestedTags = createTags([`${this.maxTags} tags max`]);
        // ... but it could have been a flash message or what you want
        // that informs the end-user the max number of tags has been reached. 
      } else {
        this.suggestedTags = await this.search(this.query);
      }
    },
    // ...
  },

So, a compromise should be to enable this behavior with a boolean prop (e.g. hide-input-on-max-tags).

What do you thing about adding this prop to your PR?

@JohMun What's your opinion?

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

2 participants