From 6095b0e2ae658d406558325511a8b2595076259d Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 15 Aug 2022 10:38:19 -0600 Subject: [PATCH] Fix Et2LinkSearch did not always get correct option when it was loaded with a value SearchMixin was incorrectly allowing it as a free entry, so it wasn't being properly loaded by Et2LinkSearch --- api/js/etemplate/Et2Link/Et2LinkSearch.ts | 2 +- api/js/etemplate/Et2Select/SearchMixin.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/js/etemplate/Et2Link/Et2LinkSearch.ts b/api/js/etemplate/Et2Link/Et2LinkSearch.ts index aabec23463..ba515361af 100644 --- a/api/js/etemplate/Et2Link/Et2LinkSearch.ts +++ b/api/js/etemplate/Et2Link/Et2LinkSearch.ts @@ -117,7 +117,7 @@ export class Et2LinkSearch extends Et2Select option.label = title || Et2Link.MISSING_TITLE; option.class = ""; // It's probably already been rendered, find the item - let item = this.getItems().find(i => i.value === option.value); + let item = this.menuItems.find(i => i.value === option.value); if(item) { item.textContent = title; diff --git a/api/js/etemplate/Et2Select/SearchMixin.ts b/api/js/etemplate/Et2Select/SearchMixin.ts index 8d145ae9a5..87502fe67c 100644 --- a/api/js/etemplate/Et2Select/SearchMixin.ts +++ b/api/js/etemplate/Et2Select/SearchMixin.ts @@ -408,7 +408,7 @@ export const Et2WithSearchMixin = >(superclass } // Overridden to add options if allowFreeEntries=true - if(typeof this.value == "string" && !this._menuItems.find(o => o.value == this.value && !o.classList.contains('remote'))) + if(this.allowFreeEntries && typeof this.value == "string" && !this._menuItems.find(o => o.value == this.value && !o.classList.contains('remote'))) { this.createFreeEntry(this.value); }