jQuery-Autocomplete
jQuery-Autocomplete copied to clipboard
ignoreValueChange prevents suggestions when selecting with keyboard
I need to implement the following workflow: user types into an input field, selects one of suggestions, then types some more, selects one of suggestions and so on. The use case is an input method for Japanese text, the user types in latin letters and the suggestions are Japanese characters. The delimiter is a regex of non-latin letters, so once a selection is chosen, the user continues to type and the suggestions are queried only for the newly typed text.
This plugin basically works perfectly, except for one little thing. I type something, get suggestions, press DOWN, press ENTER. This causes ignoreValueChange
to become true. I continue to type something, but I'm not getting suggestions anymore until I trigger onValueChange
again somehow (I'm using deferRequestBy
so onValueChange
triggers only once I finished typing.
Is there a way to circumvent ignoreValueChange being set to true via options or something? My current options are
$('#ichiran-text-field').autocomplete({
serviceUrl: '/cl/api/ime/',
paramName: 'w',
deferRequestBy: 300,
preventBadQueries: false,
delimiter: /[^a-zA-Z'\-]+/,
groupBy: "type",
triggerSelectOnValidInput: false,
onSelect: function(suggestion) {this.focus();}
})
Try setting preserveInput
option to true
. See if that works for you.
I tried that, it basically keeps the user input unchanged, which is not what I wanted. In the end I just commented out this line, and I had to add other customisation (2d navigation with up/down moving between groups and left/right moving to next/previous) which I'm not sure if anyone else needs, but the source code is available here https://ichi.moe/js/jquery.autocomplete.js
If onSelect
is triggered when using keyboard, then probably would make sense to reset ignoreValueChange
to false
inside the onSelect
.