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

Angle Field Fixes #2501

Merged
merged 5 commits into from
May 30, 2019
Merged

Conversation

BeksOmega
Copy link
Collaborator

The basics

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

The details

Resolves

N/A

Proposed Changes

  1. Fixes the angle offset property.
  2. Angle field now displays wrapped values correctly.
  3. Fixed the gauge not displaying correctly at high angle values (like the millions or something, only applies to text input)
  4. Angle field now displays zero if given empty text input.

Reason for Changes

  1. It was broken. (The below is a clockwise angle field)
    Angle_Clockwise_Offset90

  2. It was always displaying between 0 and 360. It's pretty confusing if it changes when you close th editor.

  3. This just bugged me.

  4. Angle fields should always display a number value (this is different from pure text inputs, which can be empty).

Test Coverage

I tested lots of combinations of CLOCKWISE, OFFSET, and WRAP. Here are some highlights:

  • Clockwise, Offset 90
    Angle_Clockwise_Offset90_Good!

  • Widdershins, Offset 90
    Angle_Wittershins_Offset90

  • Widdershins, Wrap 180
    Angle_Wittershins_Wrap180

  • Widdershins, Wrap 180, Offset 90
    Angle_Wittershins_Wrap180_Offset90

And here's it now working with the empty string:
Angle_EmptyString

Tested on:

  • Desktop Chrome

Additional Information

N/A

@@ -295,6 +307,7 @@ Blockly.FieldAngle.prototype.updateGraph_ = function() {
}
// Always display the input (i.e. getText) even if it is invalid.
var angleDegrees = Number(this.getText()) + Blockly.FieldAngle.OFFSET;
angleDegrees = angleDegrees % 360;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a rare opportunity to use the %= operator.

angleDegrees %= 360;

While you're at it, there's another opportunity for a %= in Blockly.FieldAngle.prototype.doClassValidation_.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oooo fun! :D

Fixed

@rachel-fenichel
Copy link
Collaborator

@NeilFraser does this look good to you now?

@rachel-fenichel rachel-fenichel merged commit 44c01ff into google:develop May 30, 2019
@BeksOmega BeksOmega deleted the fixes/AngleFields branch May 31, 2019 14:34
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.

None yet

3 participants