Skip to content

Conversation

@BenHenning
Copy link
Collaborator

@BenHenning BenHenning commented May 12, 2025

The basics

The details

Resolves

Fixes RaspberryPiFoundation/blockly-keyboard-experimentation#499

Proposed Changes

This ensures that non-blocks which hold active focus correctly update LineCursor's internal state.

Reason for Changes

This is outright a correction in how LineCursor has worked up until now, and is now possible after several recent changes (most notably #9004). #9004 updated selection to be more explicitly generic (and based on IFocusableNode) which means LineCursor should also properly support more than just blocks when synchronizing with focus (in place of selection), particularly since lots of non-block things can be focusable.

What's interesting is that this change isn't strictly necessary, even if it is a reasonable correction and improvement in the robustness of LineCursor. Essentially everywhere navigation is handled results in a call to setCurNode which correctly sets the cursor's internal state (with no specific correction from focus since only blocks were checked and we already ensure that selecting a block correctly focuses it).

Test Coverage

It would be nice to add test coverage specifically for the cursor cases, but it seems largely unnecessary since:

  1. The main failure cases are test-specific (as mentioned above).
  2. These flows are better left tested as part of broader accessibility testing (per Add tests for accessibility use cases #8915).

This has been tested with a cursory playthrough of some basic scenarios (block movement, insertion, deletion, copy & paste, context menus, and interacting with fields).

Documentation

No new documentation should be needed here.

Additional Information

This is expected to only affect keyboard navigation plugin behaviors, particularly plugin tests.

It may be worth updating LineCursor to completely reflect current focus state rather than holding an internal variable. This, in turn, may end up simplifying solving issues like #8793 (but not necessarily).

@github-actions github-actions bot added PR: fix Fixes a bug and removed PR: fix Fixes a bug labels May 12, 2025
Copy link
Collaborator Author

@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.

Self-reviewed changes.

@BenHenning BenHenning marked this pull request as ready for review May 12, 2025 22:16
@BenHenning BenHenning requested a review from a team as a code owner May 12, 2025 22:16
@BenHenning BenHenning requested a review from maribethb May 12, 2025 22:16
@BenHenning
Copy link
Collaborator Author

@gonfunko I'm curious whether you have any thoughts on this PR, as well, since it's largely touching on navigable things (which may also change with your plans to maybe remove INavigable entirely).

@gonfunko
Copy link
Contributor

Will look in depth later, but just posted #9033 which almost merges the two, leaving INavigable solely for getClass(); if we remove that, we could just have both the cursor and the focus infrastructure operate on IFocusableNodes, which would be nice.

@gonfunko
Copy link
Contributor

INavigable is gone in favor of IFocusableNode in #9037

@BenHenning
Copy link
Collaborator Author

Will update this once #9037 is merged since it will need to be essentially completely redone (but should be very straightforward to do).

…t-focused-blocks

Conflicts:
	core/interfaces/i_navigable.ts
	core/keyboard_nav/line_cursor.ts
This is also a bit simpler than the previous approach now that
INavigable has been removed.
Copy link
Collaborator Author

@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.

Self-reviewed the newer version of this that doesn't use INavigable.

@github-actions github-actions bot added PR: fix Fixes a bug and removed PR: fix Fixes a bug labels May 13, 2025
@BenHenning
Copy link
Collaborator Author

BenHenning commented May 13, 2025

FYI I will test this once RaspberryPiFoundation/blockly-keyboard-experimentation#520 is merged since I can't verify this against the current keyboard navigation plugin. However, I don't expect there to be any changes in behavior after #9037 being merged.

@github-actions github-actions bot added PR: fix Fixes a bug and removed PR: fix Fixes a bug labels May 14, 2025
@BenHenning
Copy link
Collaborator Author

Verified against the latest tip-of-tree keyboard navigation plugin and this seems to be working well. Going ahead and merging.

@BenHenning BenHenning merged commit e117980 into RaspberryPiFoundation:rc/v12.0.0 May 14, 2025
9 checks passed
@BenHenning BenHenning deleted the ensure-cursor-syncs-with-more-than-just-focused-blocks branch May 14, 2025 17:50
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