Skip to content
Merged
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
21 changes: 21 additions & 0 deletions toolbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -4904,6 +4904,16 @@ class CustomCollapsibleToolboxCategory extends Blockly.CollapsibleToolboxCategor
this.htmlDiv_?.focus?.();
}

ensureKeyboardFocusedSelection_() {
this.setExpanded(true);

const flyout = this.parentToolbox_?.getFlyout?.();
if (flyout && !flyout.isVisible?.()) {
const contents = this.getContents?.();
if (contents) flyout.show?.(contents);
}
}

// Preserve the original icon
createIconDom_() {
const img = document.createElement("img");
Expand All @@ -4918,6 +4928,10 @@ class CustomCollapsibleToolboxCategory extends Blockly.CollapsibleToolboxCategor
setSelected(isSelected) {
super.setSelected(isSelected);

if (isSelected) {
this.ensureKeyboardFocusedSelection_();
}

// Get the category color
const categoryColour = this.colour_;

Expand Down Expand Up @@ -4984,6 +4998,13 @@ class CustomCollapsibleToolboxCategory extends Blockly.CollapsibleToolboxCategor
{ capture: true },
);

this.rowDiv_.addEventListener("focusin", () => {
if (this.toolboxHasFocus_()) {
this.parentToolbox_?.setSelectedItem?.(this);
this.ensureKeyboardFocusedSelection_();
}
});

return this.htmlDiv_;
}
}
Expand Down