surveyjs / custom-widgets

The collection of custom widgets for SurveyJS: Survey Library and Survey Creator :package:
https://surveyjs.io
MIT License
79 stars 78 forks source link

EasyAutocomplete doesn't work with goNextPageAutomatic: true #266

Closed joker-777 closed 3 years ago

joker-777 commented 3 years ago

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

andrewtelnov commented 3 years ago

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

Andrew

joker-777 commented 3 years ago

@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()
}   
andrewtelnov commented 3 years ago

@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

joker-777 commented 3 years ago

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