From 5601b99c97710ceb7536eabce7f91bee492ab286 Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 12 Oct 2023 11:25:23 -0600 Subject: [PATCH] Et2Select: Add tabindex to options to avoid focus stealing in sidemenu, other event handling cleanup --- api/js/etemplate/Et2Select/Et2Select.ts | 2 +- api/js/etemplate/Et2Select/SearchMixin.ts | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/api/js/etemplate/Et2Select/Et2Select.ts b/api/js/etemplate/Et2Select/Et2Select.ts index 5569302307..1b32d59117 100644 --- a/api/js/etemplate/Et2Select/Et2Select.ts +++ b/api/js/etemplate/Et2Select/Et2Select.ts @@ -576,7 +576,6 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect) { super.et2HandleBlur(event); } - this.dropdown?.hide(); } @@ -834,6 +833,7 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect) ?clearable=${this.clearable} ?required=${this.required} helpText=${this.helpText} + tabindex="0" hoist placement=${this.placement} .getTag=${this._tagTemplate} diff --git a/api/js/etemplate/Et2Select/SearchMixin.ts b/api/js/etemplate/Et2Select/SearchMixin.ts index 96b59e70b6..99e41fd988 100644 --- a/api/js/etemplate/Et2Select/SearchMixin.ts +++ b/api/js/etemplate/Et2Select/SearchMixin.ts @@ -147,7 +147,7 @@ export const Et2WithSearchMixin = dedupeMixin( display: none; } - :host([search][multiple]) sl-select[open]::part(expand-icon) { + :host([search]) sl-select[open]::part(expand-icon) { display: none; } @@ -398,6 +398,7 @@ export const Et2WithSearchMixin = dedupeMixin( // One of the key properties has changed, need to add the needed nodes if(changedProperties.has("search") || changedProperties.has("editModeEnabled") || changedProperties.has("allowFreeEntries")) { + this._unbindListeners(); // Missing any of the required attributes? Now we need to take it out. if(!this.searchEnabled && !this.editModeEnabled && !this.allowFreeEntries || this.readonly) { @@ -405,8 +406,8 @@ export const Et2WithSearchMixin = dedupeMixin( return; } - // Normally this should be handled in render(), but we have to add our nodes in - //this._addNodes(); + // Listeners may have been skipped from connectedCallback() + this._bindListeners(); } // Update any tags if edit mode changes if(changedProperties.has("editModeEnabled") || changedProperties.has("readonly")) @@ -417,6 +418,11 @@ export const Et2WithSearchMixin = dedupeMixin( tag.editable = this.editModeEnabled && !this.readonly; tag.removable = !this.readonly; }); + + if(this.readonly) + { + this._unbindListeners(); + } } }