8000 Make all flyout items (with visual representation) focusable · Issue #8943 · google/blockly · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Make all flyout items (with visual representation) focusable #8943

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

Closed
BenHenning opened this issue Apr 30, 2025 · 6 comments
8000
Closed

Make all flyout items (with visual representation) focusable #8943

BenHenning opened this issue Apr 30, 2025 · 6 comments
Assignees
Labels
PR: feature Adds a feature

Comments

@BenHenning
Copy link
Contributor
BenHenning commented Apr 30, 2025

Arbitrary flyout items that can be added as of v12 (see #8687 for some context on how this affected the old keyboard navigation plugin).

@BenHenning
Copy link
Contributor Author

#8939 addresses the key FlyoutButton case, but a longer-term approach may be to change FlyoutItem to force an IFocusableNode as the element. This would be a breaking change unless it were done in a passive "it could be focusable" way.

@sappm01 sappm01 added the issue: triage Issues awaiting triage by a Blockly team member label Apr 30, 2025
@gonfunko
Copy link
Contributor

I don't think we can do that because not all flyout items are rendered, and therefore focusable - notably, gaps are FlyoutItems, but they aren't rendered and obviously shouldn't be focusable. They are bounded, however.

BenHenning added a commit that referenced this issue Apr 30, 2025
_Note: This is a roll forward of #8920 that was reverted in #8933. See Additional Information below._

## The basics

- [x] I [validated my changes](https://developers.google.com/blockly/guides/contribute/core#making_and_verifying_a_change)

## The details
### Resolves

Fixes #8918
Fixes #8919
Fixes part of #8943
Fixes part of #8771

### Proposed Changes

This updates several classes in order to make toolboxes and flyouts focusable:
- `IFlyout` is now an `IFocusableTree` with corresponding implementations in `FlyoutBase`.
- `IToolbox` is now an `IFocusableTree` with corresponding implementations in `Toolbox`.
- `IToolboxItem` is now an `IFocusableNode` with corresponding implementations in `ToolboxItem`.
- As the primary toolbox items, `ToolboxCategory` and `ToolboxSeparator` were updated to have -1 tab indexes and defined IDs to help `ToolboxItem` fulfill its contracted for `IFocusableNode.getFocusableElement`.
- `FlyoutButton` is now an `IFocusableNode` (with corresponding ID generation, tab index setting, and ID matching for retrieval in `WorkspaceSvg`).

Each of these two new focusable trees have specific noteworthy behaviors behaviors:
- `Toolbox` will automatically indicate that its first item should be focused (if one is present), even overriding the ability to focus the toolbox's root (however there are some cases where that can still happen).
- `Toolbox` will automatically synchronize its selection state with its item nodes being focused.
- `FlyoutBase`, now being a focusable tree, has had a tab index of 0 added. Normally a tab index of -1 is all that's needed, but the keyboard navigation plugin specifically uses 0 for flyout so that the flyout is tabbable. This is a **new** tab stop being introduced.
- `FlyoutBase` holds a workspace (for rendering blocks) and, since `WorkspaceSvg` is already set up to be a focusable tree, it's represented as a subtree to `FlyoutBase`. This does introduce some wonky behaviors: the flyout's root will have passive focus while its contents have active focus. This could be manually disabled with some CSS if it ends up being a confusing user experience.
- Both `FlyoutBase` and `WorkspaceSvg` have built-in behaviors for detecting when a user tries navigating away from an open flyout to ensure that the flyout is closed when it's supposed to be. That is, the flyout is auto-hideable and a non-flyout, non-toolbox node has then been focused. This matches parity with the `T`/`Esc` flows supported in the keyboard navigation plugin playground.

One other thing to note: `Toolbox` had a few tests to update that were trying to reinit a toolbox without first disposing of it (which was caught by one of `FocusManager`'s state guardrails).

This only addresses part of #8943: it adds support for `FlyoutButton` which covers both buttons and labels. However, a longer-term solution may be to change `FlyoutItem` itself to force using an `IFocusableNode` as its element.

### Reason for Changes

This is part of an ongoing effort to ensure key components of Blockly are focusable so that they can be keyboard-navigable (with other needed changes yet both in Core Blockly and the keyboard navigation plugin).

### Test Coverage

No new tests have been added. It's certainly possible to add unit tests for the focusable configurations being introduced in this PR, but it may not be highly beneficial. It's largely assumed that the individual implementations should work due to a highly tested FocusManager, and it may be the case that the interactions of the components working together is far more important to verify (that is, the end user flows). The latter is planned to be tackled as part of #8915.

### Documentation

No documentation changes should be needed here.

### Additional Information

This includes changes that have been pulled from #8875.

This was originally merged in #8916 but was reverted in #8933 due to google/blockly-keyboard-experimentation#481. Note that this does contain a number of differences from the original PR (namely, changes in `WorkspaceSvg` and `FlyoutButton` in order to make `FlyoutButton`s focusable). Otherwise, this has the same caveats as those noted in #8938 with regards to the experimental keyboard navigation plugin.
@BenHenning
Copy link
Contributor Author

Hmm. In that case, either we'd need to have a special case version of FlyoutItem or, at minimum, update some documentation somewhere to explain how to make an item properly focusable for keyboard navigation (i.e. hook it up like FlyoutButton). The bigger concern is that "just do what FlyoutButton does" won't actually work as advice, however, since there's a lookup component (which is done in WorkspaceSvg in this case) to actually make it work correctly.

How much are we expecting custom flyout items that are focusable and aren't part of Core? If the answer's more than zero, then we'll need to think carefully about how to make Workspace's find function composable and customizable for external configuration (I have some ideas on how this might work).

@cpcallen cpcallen changed the title Arbitrary flyout items. Make arbitrary flyout items focusable May 2, 2025
@cpcallen cpcallen added PR: feature Adds a feature and removed issue: triage Issues awaiting triage by a Blockly team member labels May 2, 2025
@BenHenning BenHenning marked this as a duplicate of #8988 May 5, 2025
@BenHenning BenHenning changed the title Make arbitrary flyout items focusable Make all flyout items focusable May 5, 2025
@BenHenning BenHenning changed the title Make all flyout items focusable Make all flyout items (with visual representation) focusable May 5, 2025
@rachel-fenichel
Copy link
Collaborator

After #9004 lands I think the state will be:

  • Blocks, block stacks, buttons, and labels are all focusable
  • Separators are not focusable
  • Arbitrary FlyoutItems are navigable but not focusable

Making FlyoutItem implement IFocusableNode will be a breaking change and is thus required for v12.

@BenHenning @gonfunko please confirm whether the above are correct.

@gonfunko
Copy link
Contributor
gonfunko commented May 9, 2025

That sounds correct.

@BenHenning
Copy link
Contributor Author

Agreed--making FlyoutItem implement IFocusableNode is probably the cleanest approach now that focusability can be made optional.

@github-project-automation github-project-automation bot moved this from Todo to Done in Blockly Accessibility May 12, 2025
@gonfunko gonfunko moved this from Done to In Progress in Blockly Accessibility May 12, 2025
@gonfunko gonfunko moved this from In Progress to Done in Blockly Accessibility May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: feature Adds a feature
Projects
Status: Done
Development

No branches or pull requests

5 participants
0