Skip to content

Conversation

@microbit-matt-hillsdon
Copy link
Contributor

@microbit-matt-hillsdon microbit-matt-hillsdon commented Mar 24, 2025

PR #326 introduced an issue with stale current node when showing the context menu by mouse. It's only possible to fix this by reinstating the updating of curNode from the selection in getCurNode.

We also attempt to avoid showing passive focus when using the context menu and widgets (via mouse and keyboard) for consistency with the normal Blockly experience.

You can now no longer get this scenario:

image

Fixes an issue clicking on shadow blocks which could previously show an outline around the shadow and parent block. You can now no longer get these scenarios:

image

image

Demo: https://fix-right-click-2.blockly-keyboard-experimentation.pages.dev/

PR RaspberryPiFoundation#326 introduced an issue with stale current node when showing the context
menu by mouse. It's only possible to fix this by reinstating the updating of
curNode from the selection.

We also attempt to avoid showing passive focus when using the context menu and
widgets (via mouse and keyboard) for consistency with the normal Blockly
experience.

Fixes an issue clicking on shadow blocks which could previously show an outline
around the shadow and parent block.
@microbit-matt-hillsdon microbit-matt-hillsdon requested a review from a team as a code owner March 24, 2025 16:15
@microbit-matt-hillsdon microbit-matt-hillsdon requested review from BenHenning and removed request for a team March 24, 2025 16:15
Copy link
Collaborator

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks @microbit-matt-hillsdon! I think the fixes make sense. I'm happy to approve the PR, though I did have a few comments on clarity. Feel free to self-resolve and merge, or assign me back if you'd like me to take another review pass.

Due to an unintentially commented out line, clicking the workspace wouldn't
clear the current node so e.g. delete would act on a block that didn't have a
visual selection.

Re-enabling that required revisiting shadow blocks to prevent getCurNode
unexpectedly clearing based on a null selection. We now always set/use the
selection for shadow blocks and take care not to move the cursor unexpectedly
as it can be in two positions for a shadow block selection.
curNode?.getType() === Blockly.ASTNode.types.BLOCK
) {
// Selection says our curNode is not selected anymore.
// this.setCurNode(null as never, true);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, this is definitely a problem. Re-enabling it threw up a shadow block issue addressed in 1233f57

Copy link
Collaborator

Choose a reason for hiding this comment

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

I actually missed this commented out bit the first time around--great catch and thanks for fixing it in the follow-up!

@microbit-matt-hillsdon
Copy link
Contributor Author

Thanks for the review @BenHenning. Assigning back as it would be good to take another look (and I can't merge it in any case).

Copy link
Collaborator

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks @microbit-matt-hillsdon. Erm, good point on the merging bit. This looks good to me!

curNode?.getType() === Blockly.ASTNode.types.BLOCK
) {
// Selection says our curNode is not selected anymore.
// this.setCurNode(null as never, true);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I actually missed this commented out bit the first time around--great catch and thanks for fixing it in the follow-up!

@BenHenning BenHenning merged commit 817e18d into RaspberryPiFoundation:main Mar 27, 2025
1 check passed
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