From 020a37ead963219a043e06ad45857077112c2664 Mon Sep 17 00:00:00 2001 From: jf-cbd Date: Fri, 17 May 2024 10:58:29 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B07526=20-=20Profile=20input=20unfocus:=20?= =?UTF-8?q?Previously=20entered=20value=20still=20filters?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/base/components/input/set/layout.ready.js.twig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/templates/base/components/input/set/layout.ready.js.twig b/templates/base/components/input/set/layout.ready.js.twig index 530bcc7c2..9f3c0d20d 100644 --- a/templates/base/components/input/set/layout.ready.js.twig +++ b/templates/base/components/input/set/layout.ready.js.twig @@ -4,6 +4,7 @@ {# SET WIDGET #} {% set oDataProvider = oUIBlock.GetDataProvider() %} +let optionsBeforeFilter; let oWidget{{ oUIBlock.GetId() }} = $('#{{ oUIBlock.GetId() }}').selectize({ {# Global options #} @@ -108,6 +109,7 @@ let oWidget{{ oUIBlock.GetId() }} = $('#{{ oUIBlock.GetId() }}').selectize({ // Filter old options data to keep selected values // (options with force flag will be kept event if they doesn't be part of the current value) let options = Object.values(me.options); + optionsBeforeFilter = options; options = options.filter(item => (typeof(item.force) !== "undefined" && item.force === true) || aSelectedItems.includes(item['{{ oDataProvider.GetDataValueField() }}'])); // Merge kept and new values options = $.merge(options, res.data.search_data); @@ -199,6 +201,11 @@ let oWidget{{ oUIBlock.GetId() }} = $('#{{ oUIBlock.GetId() }}').selectize({ CombodoTooltip.InitTooltipFromMarkup($item); }, + onBlur: function(){ + this.clearOptionGroups() + this.addOption(optionsBeforeFilter) + }, + {# plugin combodo_add_button #} {% if oUIBlock.HasAddOptionButton() and oUIBlock.HasAddOptionButtonJsOnClick() %} onAdd: function(){