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

Work around a problem with RTL mutators #1774

Merged
merged 4 commits into from
Apr 12, 2018

Conversation

rachel-fenichel
Copy link
Collaborator

The basics

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

The details

Resolves

Fixes #1425

Proposed Changes

Change the calculation of the delete area for flyouts in mutators in RTL in firefox. Explicitly add an offset from the left side of the mutator.

Reason for Changes

See #1425, but TLDR: Firefox is reporting the wrong value, and that bug has been around for years. We surfaced it with a combination of changes to our DOM structure and changes to delete logic.

Test Coverage

Tested in the playground in Firefox in RTL mode, with the if/else mutator.
Tested at a variety of scales.
Also tested in LTR mode to make sure there are no regressions.

Tested in Chrome to confirm no regressions.

Tested on:

  • Desktop Chrome
  • Desktop Firefox

Additional Information

As soon as we merge this they're going to fix Firefox and this will all break again :(

This should unblock the Blockly Games release.

@rachel-fenichel
Copy link
Collaborator Author

Updated to use the browser's value if it looks reasonable. This should protect us if Firefox eventually fixes the bug.

Copy link
Contributor

@AnmAtAnm AnmAtAnm left a comment

Choose a reason for hiding this comment

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

This makes me sad, but it is obviously the right thing to do at this point. LGTM after nit.

}
this.positionAt_(this.width_, this.height_, x, y);


Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: Excess newlines.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@rachel-fenichel
Copy link
Collaborator Author

Yeah, I'm not at all happy with it but it's been blocking for too long, and we do know exactly what conditions trigger it.

We may eventually fix the root cause the next time we work on the general DOM structure, but that's not going to be soon.

@@ -155,8 +155,13 @@ Blockly.VerticalFlyout.prototype.position = function() {
var x = targetWorkspaceMetrics.absoluteLeft;
if (this.toolboxPosition_ == Blockly.TOOLBOX_AT_RIGHT) {
x += (targetWorkspaceMetrics.viewWidth - this.width_);
// Save the location of the left edge of the flyout, for use when firefox
Copy link
Contributor

Choose a reason for hiding this comment

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

Firefox is usually capitalized.

}
this.positionAt_(this.width_, this.height_, x, y);


Copy link
Contributor

Choose a reason for hiding this comment

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

Adding blank lines?

@rachel-fenichel
Copy link
Collaborator Author

Updated the math to check whether the browser's value is right, and added a comment to explain what's going on. Thanks for the check @picklesrus!

Tested in Chrome by disabling the user-agent check. In Chrome on RTL (when the browser isn't lying) it does the right thing as well.

// visible area of the workspace should be more than ten pixels wide. If
// the browser reports that the flyout is within ten pixels of the left
// side of the workspace, ignore it and manually calculate the value.
if (Math.abs(targetWsLeftPixels - x) < 10) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Will the 10px assumption be invalidated if we allow mutators without flyouts/with empty flyouts, à la #1759. In practice, a mutator with an empty/invisible empty toolbox (no way to add new blocks), probably doesn't a need for a block delete area. Technically, the issues are distinct.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

At that point there should be no flyout, so nothing to call getClientRect on. Then this code won't be hit.

@rachel-fenichel rachel-fenichel merged commit df3e826 into google:develop Apr 12, 2018
@rachel-fenichel rachel-fenichel deleted the bugfix/1425 branch April 12, 2018 20:30
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.

4 participants