Skip to content

Conversation

@gonfunko
Copy link
Contributor

The basics

The details

Resolves

Fixes RaspberryPiFoundation/blockly-keyboard-experimentation#464

Proposed Changes

This PR updates the navigation policies to not visit connections, but instead proceed directly to the connected block/field. The connection navigation policy has been left in place for now, but is mostly unreachable (outside of a connection being selected in some cases when a block is deleted). This also makes siblings/parents/children semantically accurate for blocks, fields and the workspace, and allows simplifying the LineCursor.

@gonfunko gonfunko requested a review from a team as a code owner May 12, 2025 21:20
@gonfunko gonfunko removed the request for review from RoboErikG May 12, 2025 21:20
@rachel-fenichel rachel-fenichel changed the title Fix: don't visit connections with the cursor. fix: don't visit connections with the cursor. May 12, 2025
@github-actions github-actions bot added the PR: fix Fixes a bug label May 12, 2025
Copy link
Collaborator

@rachel-fenichel rachel-fenichel left a comment

Choose a reason for hiding this comment

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

This looks solid to me but I asked @RoboErikG to also take a look

Copy link
Contributor

@RoboErikG RoboErikG left a comment

Choose a reason for hiding this comment

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

Overall looks good and I think it can be submitted after rebasing and doing one more sanity check since I don't think you can test this in the toolbox without the recent fixes to toolboxes (I tested with a rebase, but please double check).

I also found a few issues not directly related to this change that I'll file bugs for:

  • You can't add disabled blocks to the workspace from the toolbox (so break can't be added)
  • I think if you could add a break getPreviousSibling wouldn't return it
  • Empty inputs can't be navigated to which feels wrong, especially with the list blocks, but was mentioned in another thread for discussion

// If navigating to a previous stack, our previous sibling is the last
// block in it.
if (navigatingCrossStacks && result instanceof BlockSvg) {
return result.lastConnectionInStack(false)?.getSourceBlock() ?? result;
Copy link
Contributor

Choose a reason for hiding this comment

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

Something I didn't have time to investigate, but I suspect this will return the first block in a stack if you have a termination block (blocks without a next connection) on the end of the stack. This is rare enough that it probably makes sense to fix in a follow-up issue since you'll likely need to add a method to get the last block in a stack instead of the last connection.

@gonfunko
Copy link
Contributor Author

One issue I realized this created is resolved by RaspberryPiFoundation/blockly-keyboard-experimentation#516; PTAL at that as well.

@gonfunko gonfunko merged commit ece662a into RaspberryPiFoundation:rc/v12.0.0 May 13, 2025
13 checks passed
@gonfunko gonfunko deleted the navigation-cleanup branch May 13, 2025 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: fix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants