Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/actions/arrow_navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,17 @@ export class ArrowNavigation {
}
return isHandled;
case Constants.STATE.TOOLBOX:
// @ts-expect-error private method
isHandled = toolbox && toolbox.selectChild();
if (!isHandled && flyout) {
Blockly.getFocusManager().focusTree(flyout.getWorkspace());
this.navigation.defaultFlyoutCursorIfNeeded(workspace);
if (toolbox) {
const selectedItem = toolbox.getSelectedItem();
// Don't auto-expand collapsible items. 'Enter' should be used.
if (selectedItem && !selectedItem.isCollapsible()) {
// @ts-expect-error private method
isHandled = toolbox.selectChild();
}
if (!isHandled && flyout) {
Blockly.getFocusManager().focusTree(flyout.getWorkspace());
this.navigation.defaultFlyoutCursorIfNeeded(workspace);
}
}
return true;
default:
Expand Down
15 changes: 13 additions & 2 deletions src/actions/enter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import {
Events,
Msg,

Check warning on line 9 in src/actions/enter.ts

View workflow job for this annotation

GitHub Actions / Eslint check

'Msg' is defined but never used
ShortcutRegistry,
utils as BlocklyUtils,
getFocusManager,
Expand All @@ -19,7 +19,7 @@
FocusableTreeTraverser,
} from 'blockly/core';

import type {Block} from 'blockly/core';
import type {Block, ICollapsibleToolboxItem, Toolbox} from 'blockly/core';

import * as Constants from '../constants';
import type {Navigation} from '../navigation';
Expand Down Expand Up @@ -62,6 +62,8 @@
let flyoutCursor;
let curNode;

const toolbox = workspace.getToolbox() as Toolbox;

switch (this.navigation.getState(workspace)) {
case Constants.STATE.WORKSPACE:
this.handleEnterForWS(workspace);
Expand All @@ -77,7 +79,16 @@
} else if (curNode instanceof FlyoutButton) {
this.triggerButtonCallback(workspace);
}

return true;
case Constants.STATE.TOOLBOX:
if (toolbox) {
const selectedItem = toolbox.getSelectedItem();
// Only navigate for collapsible items.
if (selectedItem && selectedItem.isCollapsible()) {
(selectedItem as ICollapsibleToolboxItem).toggleExpanded();
toolbox.refreshSelection();
}
}
return true;
default:
return false;
Expand Down
Loading