From a2bd4afd14411ac77cc78a9dc9dfa7a507990496 Mon Sep 17 00:00:00 2001 From: Katrin Khilko Date: Tue, 15 Oct 2024 16:33:09 +0300 Subject: [PATCH] FIO-9205: fixed an issue where Select Filter feature does not work --- src/components/select/Select.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/components/select/Select.js b/src/components/select/Select.js index 972bfb3080..98bfb2e64a 100644 --- a/src/components/select/Select.js +++ b/src/components/select/Select.js @@ -1454,7 +1454,7 @@ export default class SelectComponent extends ListComponent { return super.normalizeValue(this.normalizeSingleValue(value)); } - setMetadata(value) { + setMetadata(value, flags = {}) { if (_.isNil(value)) { return; } @@ -1490,16 +1490,23 @@ export default class SelectComponent extends ListComponent { _.set(submission.metadata.selectData, this.path, templateData); } + if (flags.resetValue && this.root?.submission) { + const submission = this.root.submission; + if (!submission.metadata) { + submission.metadata = {}; + } + submission.metadata.selectData = {}; + } } updateValue(value, flags) { const changed = super.updateValue(value, flags); - if (changed || !this.selectMetadata) { + if (changed || !this.selectMetadata || flags.resetValue) { if (this.component.multiple && Array.isArray(this.dataValue)) { - this.dataValue.forEach(singleValue => this.setMetadata(singleValue)); + this.dataValue.forEach(singleValue => this.setMetadata(singleValue, flags)); } else { - this.setMetadata(this.dataValue); + this.setMetadata(this.dataValue, flags); } } return changed;