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

Chasing reporter block around in zelos #7426

Closed
1 task done
rachel-fenichel opened this issue Aug 23, 2023 · 7 comments · Fixed by #7482
Closed
1 task done

Chasing reporter block around in zelos #7426

rachel-fenichel opened this issue Aug 23, 2023 · 7 comments · Fixed by #7482
Labels
issue: bug Describes why the code or behaviour is wrong size: small Bugs that can be picked up and completed in 1-3 days

Comments

@rachel-fenichel
Copy link
Collaborator

Check for duplicates

  • I have searched for similar issues before opening a new one.

Description

This bug was originally reported in #7412 by @clementcontet

See the screenshot for the originally reported bug.

I think the mechanism is: Sometimes when the insertion marker appears it moves the valid connection far enough away from the target connection that it becomes invalid, which makes the target block disconnect and get bumped away from the dragging block.

This is more likely to happen when using zelos because it changes the height of the input and moves the connection location down, while geras and thrasos leave the connection in the same location relative to the top left of the dragging block.

To verify: try the same drag with taller and shorter value blocks. The problem should become more visible the taller the value block is.

Reproduction steps

Stack trace

No response

Screenshots

261792452-91c9a89e-e6e5-47e5-aa88-5ddaddaa3508.mov

Browsers

No response

@rachel-fenichel rachel-fenichel added issue: bug Describes why the code or behaviour is wrong issue: triage Issues awaiting triage by a Blockly team member labels Aug 23, 2023
@clementcontet
Copy link
Contributor

Hi Rachel,

Indeed I don't have the problem with small child blocks, or when switching to Geras.

But I found that even when the connection is done directly (without "chasing"), when the insertion marker appears, it appears at a place that makes the child block to be moved below.
Whereas in Geras, the insertion marker appears at the exact place that matches the child block current position.

child.block.moved.mov

@rachel-fenichel
Copy link
Collaborator Author

The fix would be to note the difference between the position of the connection when the value input is expanded vs the position of the connection when the value input is at its default size, and to shift the parent bock up and left by that difference.

But this would cause a different problem: the dragged block would have to jump relative to the mouse. I think that would be worse. What do you think?

@clementcontet
Copy link
Contributor

the dragged block would have to jump relative to the mouse

We would first see the insertion marker of the block on its target position, right?
In that case, the "jump" would only occur when we drop the dragged block, and it would indeed be placed at the exact place of the insertion marker.

And I think we already see this "jump" with insertion marker:

insertion.marker.moved.mov

@rachel-fenichel
Copy link
Collaborator Author

You're correct. Okay, we'll look at getting the marker to position so that the connecting block doesn't have to move.

@maribethb maribethb added size: small Bugs that can be picked up and completed in 1-3 days and removed issue: triage Issues awaiting triage by a Blockly team member labels Aug 30, 2023
@rachel-fenichel
Copy link
Collaborator Author

@clementcontet If you want to fix this, take a look at the positionNearConnection function in block_svg.ts

@clementcontet
Copy link
Contributor

Hi @rachel-fenichel, I tried to implement what you described, but I was a bit lost and I'm not sure I did well.

The fix would be to note the difference between the position of the connection when the value input is expanded vs the position of the connection when the value input is at its default size, and to shift the parent bock up and left by that difference

take a look at the positionNearConnection function in block_svg.ts

I didn't find a way to get the expanded input in positionNearConnection, so I had to implement something after the renderer has finished.

But if I only moved the insertion marker after the render, it didn't work either (I guess because the insertion marker would not be placed correctly next to the target connection and the renderer fails?).

So my solution was to keep intact the current move before the render, and after the render, move it again according the displacement of the expanded input.

Is it the right way to do it?

@rachel-fenichel
Copy link
Collaborator Author

rachel-fenichel commented Sep 11, 2023

Hi Clement,

Sorry for the delay in responding.

Yes, your solution looks reasonable (in this commit).

Your analysis is correct: the blocks have to be connected before you can figure out the new location of the connection, which means that repositioning has to happen after connecting instead of before. Doing it that way is also more general than the existing positionNearConnection method, so you should be able to remove positionNearConnection and have your new method handle all of the cases it handled.

To avoid flickering, you should also move the insertionMarker?.getSvgRoot().setAttribute('visibility', 'visible'); line to just after your resize, instead of just before.

If you put those changes into a PR, we'll happily review and take them.

rachel-fenichel added a commit that referenced this issue Sep 13, 2023
fix: insertion marker position when connection is resized (#7426)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Describes why the code or behaviour is wrong size: small Bugs that can be picked up and completed in 1-3 days
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants