From 963f6cb3c983e3067ccae4a449fdab435a86e407 Mon Sep 17 00:00:00 2001 From: Dr Tracy Gardner Date: Sun, 8 Mar 2026 14:47:21 +0000 Subject: [PATCH 1/3] Expand toolbox subcategories on keyboard focus --- toolbox.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/toolbox.js b/toolbox.js index 435d12f5..4fa381b8 100644 --- a/toolbox.js +++ b/toolbox.js @@ -4904,6 +4904,18 @@ class CustomCollapsibleToolboxCategory extends Blockly.CollapsibleToolboxCategor this.htmlDiv_?.focus?.(); } + ensureKeyboardFocusedSelection_() { + this.parentToolbox_?.setSelectedItem?.(this); + this.setSelected(true); + 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"); @@ -4984,6 +4996,12 @@ class CustomCollapsibleToolboxCategory extends Blockly.CollapsibleToolboxCategor { capture: true }, ); + this.rowDiv_.addEventListener("focusin", () => { + if (this.toolboxHasFocus_()) { + this.ensureKeyboardFocusedSelection_(); + } + }); + return this.htmlDiv_; } } From e733fdbcd9078b5b0ddda3390654a7a4e41e3b97 Mon Sep 17 00:00:00 2001 From: Dr Tracy Gardner Date: Sun, 8 Mar 2026 15:21:22 +0000 Subject: [PATCH 2/3] Fix keyboard-triggered toolbox subcategory expansion --- toolbox.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/toolbox.js b/toolbox.js index 4fa381b8..53f494c2 100644 --- a/toolbox.js +++ b/toolbox.js @@ -4830,6 +4830,10 @@ class IconCategory extends Blockly.ToolboxCategory { setSelected(isSelected) { super.setSelected(isSelected); + if (isSelected) { + this.ensureKeyboardFocusedSelection_(); + } + // Get the category color const categoryColour = this.colour_; @@ -4905,8 +4909,6 @@ class CustomCollapsibleToolboxCategory extends Blockly.CollapsibleToolboxCategor } ensureKeyboardFocusedSelection_() { - this.parentToolbox_?.setSelectedItem?.(this); - this.setSelected(true); this.setExpanded(true); const flyout = this.parentToolbox_?.getFlyout?.(); @@ -4930,6 +4932,10 @@ class CustomCollapsibleToolboxCategory extends Blockly.CollapsibleToolboxCategor setSelected(isSelected) { super.setSelected(isSelected); + if (isSelected) { + this.ensureKeyboardFocusedSelection_(); + } + // Get the category color const categoryColour = this.colour_; @@ -4998,6 +5004,7 @@ class CustomCollapsibleToolboxCategory extends Blockly.CollapsibleToolboxCategor this.rowDiv_.addEventListener("focusin", () => { if (this.toolboxHasFocus_()) { + this.parentToolbox_?.setSelectedItem?.(this); this.ensureKeyboardFocusedSelection_(); } }); From a508c9357d42b7c1b45e9f3f320fbf92d75384a4 Mon Sep 17 00:00:00 2001 From: Dr Tracy Gardner Date: Sun, 8 Mar 2026 15:44:25 +0000 Subject: [PATCH 3/3] Fix category click regression in toolbox selection --- toolbox.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/toolbox.js b/toolbox.js index 53f494c2..a38c4320 100644 --- a/toolbox.js +++ b/toolbox.js @@ -4830,10 +4830,6 @@ class IconCategory extends Blockly.ToolboxCategory { setSelected(isSelected) { super.setSelected(isSelected); - if (isSelected) { - this.ensureKeyboardFocusedSelection_(); - } - // Get the category color const categoryColour = this.colour_;