Choices-js/Choices

Notice for max item limit is removed permanently if you keep typing

Closed this issue · 3 comments

Describe the bug
The element that shows the message Only ${maxItemCount} values can be added after the item limit is reached disappears too early and cannot be triggered again. After the limit is reached, if you type one character the message is shown in the dropdown. If you type one or more extra characters, the element is removed completely and permanently (unless you reload the page). It does not re-appear after deleting the text and typing again, or after leaving and re-entering the input. The issue occurs with type text and type select-multiple.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://choices-js.github.io/Choices/
  2. Go to the first example under Text inputs.
  3. Add items until the limit of 5 is reached.
  4. Type one character to make the notice Only 5 values can be added appear.
  5. Type another character to make the same notice disappear.

Expected behavior
I would expect that the notice stays even if you type more than one character and that it re-appears if you clear the search input and make another attempt of adding or searching an item.

Screenshots
Not applicable.

Choices version and bundle

  • Version: v11.0.2

Desktop (please complete the following information):

  • OS: Ubuntu 22.04
  • Browser: Firefox
  • Version: 130

Smartphone (please complete the following information):
Not applicable.

Additional context
None.

Xon commented

I will look into this early next week, as it looks like the logic on when or what a notice gets added needs more work.

Thank you! 🙂

I don't have time to create a PR for this, however if you throw a this._renderNotice(); before the early return for displayNotice it will solve the issue.