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

Propagate the visible state when blocks connect #2003

Merged
merged 3 commits into from
Apr 15, 2019

Conversation

RoboErikG
Copy link
Contributor

@RoboErikG RoboErikG commented Aug 14, 2018

This fixes #1967.

In rendered connections when connecting:

  • If the superior connection is hidden this hides the newly connected block.
  • If the superior connection isn't hidden it makes sure the block is visible.

In rendered connections when disconnecting:

  • If the superior connection is hidden, make the disconnected block stack visible.

TODO before review: write tests.

The basics

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

The details

Resolves

#1967

Proposed Changes

Adds logic to rendered_connection to hide or unhide blocks when they are connected to a hidden connection.

Reason for Changes

If you programatically connect a block to a hidden connection the block remains visible and gets placed in a random spot. The block should be hidden when connected and unhidden when disconnected.

Test Coverage

Tested on:
Desktop Chrome

Additional Information


This change is Reviewable

@RoboErikG RoboErikG force-pushed the roboerikg-connectionHideAll branch 2 times, most recently from 79b7dc0 to fc087ed Compare August 15, 2018 19:47
@RoboErikG
Copy link
Contributor Author

This still needs more work. It seems to be working, but there were quite a few edge cases that I had to fix and I don't think I've caught them all.

@AnmAtAnm
Copy link
Contributor

Four lint errors in rendered_connection.js:

337:36  error  Trailing spaces not allowed  no-trailing-spaces
343:64  error  Missing semicolon            semi
347:2   error  Missing semicolon            semi
365:2   error  Missing semicolon            semi



function renderedConnectionTest_setup() {

Copy link
Contributor

Choose a reason for hiding this comment

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

Intending to complete these before merging?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I need to write tests still. Probably won't happen for a week or two.

core/rendered_connection.js Show resolved Hide resolved

/**
* Disconnect this connection.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

@override

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Blockly.RenderedConnection.prototype.connect = function(otherConnection) {
Blockly.RenderedConnection.superClass_.connect.call(this, otherConnection);
// This is a quick check to make sure we aren't doing unecessary work.
if (this.hidden_ || otherConnection.hidden_) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there actually a need to test the inferior connection? I can't think of one, though test both does seem safer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's easier to just check both rather than verify which is the inferior connection.

This fixes google#1967.

In rendered connections when connecting:
- If the superior connection is hidden this hides the newly connected block.
- If the superior connection isn't hidden it makes sure the block is visible.

In rendered connections when disconnecting:
- If the superior connection is hidden, make the disconnected block stack visible.

TODO before review:
 - write tests.
 - update collapsed message
@RoboErikG RoboErikG force-pushed the roboerikg-connectionHideAll branch from 9263f4e to b071b4f Compare April 5, 2019 23:04
@RoboErikG
Copy link
Contributor Author

Tests added! This PR is now ready to go once there's a final review.

@RoboErikG RoboErikG force-pushed the roboerikg-connectionHideAll branch 2 times, most recently from ea86e22 to 907d312 Compare April 15, 2019 23:19
@RoboErikG RoboErikG merged commit ec78eeb into google:develop Apr 15, 2019
RoboErikG added a commit to RoboErikG/blockly that referenced this pull request Jul 19, 2019
@RoboErikG RoboErikG mentioned this pull request Jul 19, 2019
3 tasks
rachel-fenichel added a commit that referenced this pull request Jul 20, 2019
rachel-fenichel pushed a commit that referenced this pull request Jul 20, 2019
@RoboErikG RoboErikG deleted the roboerikg-connectionHideAll branch October 8, 2019 21:48
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