surveyjs / survey-creator

Scalable open-source survey software to generate dynamic JSON-driven forms within your JavaScript application. The form builder features a drag-and-drop UI, CSS Theme Editor, and GUI for conditional logic and form branching.
https://surveyjs.io/open-source
Other
862 stars 363 forks source link

[Knockout] A Text field receives an unexpected value after changing the input type #5463

Open JaneSjs opened 2 months ago

JaneSjs commented 2 months ago

T18022 - Value not reset on change from text->color->text https://surveyjs.answerdesk.io/internal/ticket/details/T18022


Please follow these steps to reproduce the issue: Change the input type from Text to Color and then back to Text. The #000000 value appears:

https://github.com/surveyjs/survey-creator/assets/22372972/bda55508-bcbd-4be7-a8c6-89eb0e4854ca

andrewtelnov commented 2 months ago

The problem is in knockout. question.koValue() returns an empty array and changing question.koValue() does't seems to change anything. The input continiues to show empty color value.

tsv2013 commented 1 month ago

This is the default behavior for an input element. If you change the input type from color to text, the "#000000" color value is a valid string and it will be preserved as an input element value. It seems like framevorks like react, angular and others update value from a virtual dom, but knockoutjs doesn't do it. We plan to get rid of survey-knockout in V2. On the other hand, this issue doesn't seem critical. That's why we won't fix it right now. I marked it as a known issue. We will keep it open.