@@ -97,7 +97,7 @@ export class ToolboxSearchCategory extends Blockly.ToolboxCategory {
9797 callback : ( ) => {
9898 const position = this . getPosition ( ) ;
9999 if ( position < 0 ) return false ;
100- this . parentToolbox_ . selectItemByPosition ( position ) ;
100+ Blockly . getFocusManager ( ) . focusNode ( this ) ;
101101 return true ;
102102 } ,
103103 keyCodes : [ shortcut ] ,
@@ -137,33 +137,23 @@ export class ToolboxSearchCategory extends Blockly.ToolboxCategory {
137137 this . blockSearcher . indexBlocks ( [ ...availableBlocks ] ) ;
138138 }
139139
140- /**
141- * Handles a click on this toolbox category.
142- *
143- * @param e The click event.
144- */
145- override onClick ( e : Event ) {
146- super . onClick ( e ) ;
147- e . preventDefault ( ) ;
148- e . stopPropagation ( ) ;
149- this . setSelected ( this . parentToolbox_ . getSelectedItem ( ) === this ) ;
140+ /** See IFocusableNode.getFocusableElement. */
141+ override getFocusableElement ( ) : HTMLElement | SVGElement {
142+ if ( ! this . searchField ) {
143+ throw Error ( 'This field currently has no representative DOM element.' ) ;
144+ }
145+ return this . searchField ;
150146 }
151147
152- /**
153- * Handles changes in the selection state of this category.
154- *
155- * @param isSelected Whether or not the category is now selected.
156- */
157- override setSelected ( isSelected : boolean ) {
158- super . setSelected ( isSelected ) ;
148+ /** See IFocusableNode.onNodeFocus. */
149+ override onNodeFocus ( ) : void {
150+ this . matchBlocks ( ) ;
151+ }
152+
153+ /** See IFocusableNode.onNodeBlur. */
154+ override onNodeBlur ( ) : void {
159155 if ( ! this . searchField ) return ;
160- if ( isSelected ) {
161- this . searchField . focus ( ) ;
162- this . matchBlocks ( ) ;
163- } else {
164- this . searchField . value = '' ;
165- this . searchField . blur ( ) ;
166- }
156+ this . searchField . value = '' ;
167157 }
168158
169159 /**
0 commit comments