From 62f876de1293297110a09540fb07df4200860017 Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 18 Sep 2024 14:05:58 -0600 Subject: [PATCH] Et2TreeDropdown: hide popup on escape --- api/js/etemplate/Et2Tree/Et2TreeDropdown.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/api/js/etemplate/Et2Tree/Et2TreeDropdown.ts b/api/js/etemplate/Et2Tree/Et2TreeDropdown.ts index 9ee80b14f0..fb9279f025 100644 --- a/api/js/etemplate/Et2Tree/Et2TreeDropdown.ts +++ b/api/js/etemplate/Et2Tree/Et2TreeDropdown.ts @@ -439,7 +439,7 @@ export class Et2TreeDropdown extends SearchMixin & Et2InputWidg /** * Keyboard events that the search input did not grab - * (tags, otion navigation) + * (tags, option navigation) * * @param {KeyboardEvent} event */ @@ -493,6 +493,15 @@ export class Et2TreeDropdown extends SearchMixin & Et2InputWidg { this._searchNode.focus(); } + event.stopPropagation(); + return; + } + // Close popup if focus is on tree + if(["Escape"].includes(event.key)) + { + this.hide(); + event.stopPropagation(); + return; } } @@ -594,6 +603,13 @@ export class Et2TreeDropdown extends SearchMixin & Et2InputWidg { super.handleSearchKeyDown(event); + // Hide popup if focus is on search + if(["Escape"].includes(event.key)) + { + this.hide(); + event.stopPropagation(); + return; + } // Show options if popup is closed if(event.key == "ArrowDown" && !this.open && !this.resultsOpen) { @@ -958,6 +974,7 @@ export class Et2TreeDropdown extends SearchMixin & Et2InputWidg ?leafOnly = ${this.leafOnly} @blur=${this.handleInternalBlur} + @keydown=${this.handleComboboxKeyDown} @sl-selection-change=${this.handleTreeChange} >