Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compare strings without converting to number, "77" not equals to "077" #2000

Closed
xxxKOTxxx opened this issue Feb 21, 2020 · 12 comments
Closed

Compare strings without converting to number, "77" not equals to "077" #2000

xxxKOTxxx opened this issue Feb 21, 2020 · 12 comments
Labels
Milestone

Comments

@xxxKOTxxx
Copy link

@xxxKOTxxx xxxKOTxxx commented Feb 21, 2020

I have a problem with text field updating. I found this issue while tesing zip code field.

Reporting a bug

How would you reproduce the current behavior (if this is a bug)?

To reproduce bug need to enter numeric string with leading zeros f.e. "0077" and store survey data (go to next page).

Then if we return to previous page and change input value to "77" or "077" and try to update survey result no changes will be stored.

What is the current behavior?

If we return we'll see "0077" in this input.

What is the expected behavior?

Value must be changed

Possible reason

I think the problem is in unstrict comparing in change detection.
"0077" == 77 but "0077" !== 77.
If number from string value changing everything works as expected.

Please check it.

Best regards,
Boris

Specify your

  • browser: Chrome
  • browser version: Version 80.0.3987.106 (Official Build) (64-bit)
  • surveyjs platform (angular or react or jquery or knockout or vue): React
  • surveyjs version: 1.5.9
@tsv2013 tsv2013 added the question label Feb 21, 2020
@tsv2013

This comment has been minimized.

Copy link
Member

@tsv2013 tsv2013 commented Feb 21, 2020

I've created a live sample - https://next.plnkr.co/edit/X9ITVFDWjaefEwHN
It works ok for me? Do I miss something?

@xxxKOTxxx

This comment has been minimized.

Copy link
Author

@xxxKOTxxx xxxKOTxxx commented Feb 21, 2020

Thank You for fast reply!

I've created a live sample - https://next.plnkr.co/edit/X9ITVFDWjaefEwHN
It works ok for me? Do I miss something?

I'll try to illustrate in this fork - https://next.plnkr.co/edit/JWeYKRAmb6fMjw1A?preview

Please, take attention to onValueChanged callback fireing.

I'm using backend storage and synchronize data on page changing.

@xxxKOTxxx

This comment has been minimized.

Copy link
Author

@xxxKOTxxx xxxKOTxxx commented Feb 25, 2020

Interesting, that onValueChanging working as expected, but onValueChanged - no.

@andrewtelnov

This comment has been minimized.

Copy link
Member

@andrewtelnov andrewtelnov commented Feb 25, 2020

@xxxKOTxxx You should not use question.setValueCore function. In fact, it is protected and as result it doesn't exists in minimized version of the library.
What you are trying to do?

Thank you,
Andrew

@xxxKOTxxx

This comment has been minimized.

Copy link
Author

@xxxKOTxxx xxxKOTxxx commented Feb 25, 2020

@xxxKOTxxx You should not use question.setValueCore function. In fact, it is protected and as result it doesn't exists in minimized version of the library.
What you are trying to do?

I apologize - I inadvertently saved this.
Returned to the previous state.
The idea was, as a temporary measure, to check for erroneous behavior and manually set the value.

Thank you for your comment

@andrewtelnov

This comment has been minimized.

Copy link
Member

@andrewtelnov andrewtelnov commented Feb 25, 2020

@xxxKOTxxx What is wrong with your plunker? I added debugger; into onValueChanged event. The debugger stopped two times as well as in onValueChanging. Everything works as expected.

PS: We have several unit tests on this functionality. It is unlikely that it is broken.

Thank you,
Andrew

@xxxKOTxxx

This comment has been minimized.

Copy link
Author

@xxxKOTxxx xxxKOTxxx commented Feb 25, 2020

@andrewtelnov, sorry - I had no time to create more clear plunker.

Try this one https://next.plnkr.co/edit/0BdxsoQx5DqwJPiG

I added normal output and steps to reproduce.

I hope it's enough to understand what is wrong. Maybe I don't understand something - if so, I'll be glad if You point out my error.

@andrewtelnov

This comment has been minimized.

Copy link
Member

@andrewtelnov andrewtelnov commented Feb 28, 2020

@xxxKOTxxx I think I finally got you!
You mean that SurveyJS consider "10" equals "010". Am I correct?
I guess we can fix it.

Thank you,
Andrew

@xxxKOTxxx

This comment has been minimized.

Copy link
Author

@xxxKOTxxx xxxKOTxxx commented Feb 29, 2020

You mean that SurveyJS consider "10" equals "010". Am I correct?

Yes! I'll be very glad if You fix it.

Thank You!

@andrewtelnov andrewtelnov changed the title Problem with input content update Compare strings without converting to number, "77" not equals to "077" Feb 29, 2020
@andrewtelnov andrewtelnov added bug and removed question labels Feb 29, 2020
@andrewtelnov

This comment has been minimized.

Copy link
Member

@andrewtelnov andrewtelnov commented Feb 29, 2020

@xxxKOTxxx The bug is fixed via commit above.

Thank you,
Andrew

@andrewtelnov andrewtelnov added the fixed label Feb 29, 2020
@andrewtelnov andrewtelnov added this to the v1.5.12 milestone Feb 29, 2020
@xxxKOTxxx

This comment has been minimized.

Copy link
Author

@xxxKOTxxx xxxKOTxxx commented Mar 3, 2020

@andrewtelnov Thank You!

As I understand we can get this fix in v1.5.13?

When do You planning to release it?

@andrewtelnov

This comment has been minimized.

Copy link
Member

@andrewtelnov andrewtelnov commented Mar 3, 2020

@xxxKOTxxx We will release v1.5.13 hopefully tomorrow, but definately on this week.

Thank you,
Andrew

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.