surveyjs/custom-widgets

EasyAutocomplete doesn't work with goNextPageAutomatic: true

joker-777 opened this issue · 4 comments

Hi, the problem is that you use onSelectItemEvent to select the question value instead of onChooseEvent. This will automatically evaluate the question when hovering over any of the autocomplete options.
https://github.com/surveyjs/custom-widgets/blob/master/src/easy-autocomplete.js#L77

@joker-777 That you for reporting and for the tip.

Andrew

@andrewtelnov Thanks for fixing this so quickly. I found another problem that was much more complicated. Using goNextPageAutomatic: true, a text input field will evaluate automatically onBlur event which also happens when you click on one of the easyAutocomplete options. This means it automatically uses the text you typed in instead of the option you clicked on.
My workaround, for now, is to overwrite question.correctValueType but I hope there is/will be a more elegant solution.

question.correctValueType = () => {
  if ($el.getSelectedItemData() < 0) return
  return $el.getSelectedItemData()
}   

@joker-777 I believe it makes sense just to remove goNextPageAutomatic functionality support from this widget. Easy complete fires onBlue before selecting the value from the list and we have to apply the value. We can't use corretValueType, at first it is protected, but it is not the main point. Easy complete allows to enter any text and we will kill this functionality in this case.
Plus, why don't you use dataList property of the text question. It works pretty similar and it works out of the box. Here is the example.

Thank you,
Andrew

You are probably right. I also realized that the select2 field is actually a much better fit for my use case.