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

do value update if the value is valid again #4351

Merged
merged 4 commits into from
Oct 7, 2020

Conversation

halitanildonmez
Copy link
Contributor

The basics

  • I branched from develop
  • My pull request is against develop
  • My code follows the style guide

The details

Resolves

#4345

Proposed Changes

The issue was, in the field, if the user has entered invalid once the flag isTextValid_; was being set to false at doValueInvalid_ which is fine. If however the user enters correct value, then the flag is never se to true.

I made it so that at field.js processValidation_ we do doValueUpdate_ so that we update the flag.

Reason for Changes

To solve the bug that was opened.

Test Coverage

Tested on:
Desktop Chrome
Desktop Firefox

Documentation

Additional Information

@BeksOmega
Copy link
Collaborator

Hello @halitanildonmez Thanks for submitting a fix for this :D

I think that you're definitely looking in the right spot wrt the bug you mentioned! But I think it might be better to modify the logic of the setValue function, rather than modify the processValidation_ function. With the current fix it might run into problems with doValueUpdate_ and forceRerender getting called on values that pass the class validator, but not the local validator. I don't think this would cause bad behavior or anything, but rerenders can be pretty expensive, so it's best to minimize them when possible. Do you feel like that's workable?

And it seems like the travis build failed because some mocha tests need to be updated for the new behavior. These tests are located in your my-blockly-clone/tests/mocha directory. There is also an index.html file in that directory, and if you open that in your browser it will give you more details about what tests are passing/failing.

Specifically it looks like some sinon assertions need updates, so the sinon assertions docs might be helpful.

Thank you again for the submission! I know the fields stuff can be kind of a mess hehe so thanks for digging through it :D If you have any questions/comments obviously please feel free to reply!

@halitanildonmez
Copy link
Contributor Author

Hello @BeksOmega !

Thank you for the feedback and the help! 😄 I have fixed it with the last two commits (i hope) and hope it looks better now.

Let me know if you want me to change something else 😄

@halitanildonmez
Copy link
Contributor Author

one note, I changed the tests to calledOnce for value update, hope that is ok

@BeksOmega
Copy link
Collaborator

Looks perfect! Thank you for the updates @halitanildonmez :D

@halitanildonmez
Copy link
Contributor Author

Awesome! So glad to hear 😄

Copy link
Contributor

@alschmiedt alschmiedt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great!

Just one comment and then lgtm.

core/field.js Outdated
@@ -899,6 +899,7 @@ Blockly.Field.prototype.setValue = function(newValue) {
var oldValue = this.getValue();
if (oldValue === newValue) {
doLogging && console.log('same, return');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be updated to reflect the change. Something like 'same, doValueUpdate_ then return'.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed it! 😄 thank you for the input!

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

Successfully merging this pull request may close these issues.

3 participants