Skip to content

Commit ffb4d04

Browse files
authored
fix: make toolbox search focusable (#2612)
1 parent 9d2147d commit ffb4d04

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

plugins/toolbox-search/src/toolbox_search.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {BlockSearcher} from './block_searcher';
2020
export class ToolboxSearchCategory extends Blockly.ToolboxCategory {
2121
private static readonly START_SEARCH_SHORTCUT = 'startSearch';
2222
static readonly SEARCH_CATEGORY_KIND = 'search';
23+
private readonly SEARCH_INPUT_ID = 'toolbox-search-input';
2324
private searchField?: HTMLInputElement;
2425
private blockSearcher = new BlockSearcher();
2526

@@ -50,6 +51,7 @@ export class ToolboxSearchCategory extends Blockly.ToolboxCategory {
5051
protected override createDom_(): HTMLDivElement {
5152
const dom = super.createDom_();
5253
this.searchField = document.createElement('input');
54+
this.searchField.id = this.SEARCH_INPUT_ID;
5355
this.searchField.type = 'search';
5456
this.searchField.placeholder = 'Search';
5557
this.workspace_.RTL
@@ -58,7 +60,7 @@ export class ToolboxSearchCategory extends Blockly.ToolboxCategory {
5860
this.searchField.addEventListener('keyup', (event) => {
5961
if (event.key === 'Escape') {
6062
this.parentToolbox_.clearSelection();
61-
return true;
63+
return;
6264
}
6365

6466
this.matchBlocks();
@@ -67,6 +69,11 @@ export class ToolboxSearchCategory extends Blockly.ToolboxCategory {
6769
return dom;
6870
}
6971

72+
/** The ID of the toolbox item must match the ID of the focusable node. */
73+
override getId(): string {
74+
return this.SEARCH_INPUT_ID;
75+
}
76+
7077
/**
7178
* Returns the numerical position of this category in its parent toolbox.
7279
*

0 commit comments

Comments
 (0)