MinChar interferes with clearing the input
lukasoppermann opened this issue · 9 comments
When a minCharacters
option is set, the result is not refreshed when the input is empty.
Aha, that's a good observation. This can be fixed by disabling the minCharacters
check on "initialisation" or reset. You are talking about the h.clear()
, right?
Actually no, I am talking about deleting everything from the input by keyboard or by clicking the (X) button that some browser show by default to clear the input.
Maybe you can detect it using the input
event? In any case, there is also a reset
event which is triggered. But probably the easiest would be to trigger a search if the input is empty or has more chars than defined in minCharacters
.
Okay that makes sense, that was a downside I saw on minCharacters
. So then minCharacters
should only run if the length is longer than before, so it would only run in front direction. But then it would get called like this:
// minCharacters: 3
//current:
// not called
a // not called
aa // not called
aaa // not called
aaaa // called
aaa // not called
aa // not called
a // not called
// not called
a // not called
//new:
// not called
a // not called
aa // not called
aaa // not called
aaaa // called
aaa // called
aa // called
a // called
// called
a // not called
What do you think about that?
Wouldn't it be like this:
a // not called
aa // not called
aaa // not called
aaaa // called
aaa // called
aa // not called
a // not called
// called
a // not called
ok, so you want an exception for 0 characters then?
Exactly. This is a UX question for me. As a user I expect that when I empty the input, the search resets. Of course I can add it myself, but I think it would be a very sensible thing to add.
If you think it is not a use-case for everybody it would be an option you can disable restOnEmpty = false
. Although I current do not see where it could cause harm.
Okay, makes sense. I wasn't 100% Sure either, adding it now :)
This is now available in v1.11.1
Tested, works like a charm.