From 677171babf2299ac04de0d3f219fc7b2db77a6d4 Mon Sep 17 00:00:00 2001 From: vashjs Date: Fri, 20 Oct 2023 08:46:56 +0100 Subject: [PATCH] refactor getTransformedValue --- src/QueryBuilder/QueryBuilder/helpers/query.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/QueryBuilder/QueryBuilder/helpers/query.js b/src/QueryBuilder/QueryBuilder/helpers/query.js index 4743f65f..f29b452b 100644 --- a/src/QueryBuilder/QueryBuilder/helpers/query.js +++ b/src/QueryBuilder/QueryBuilder/helpers/query.js @@ -36,9 +36,16 @@ export const isQueryValid = (source) => { }; export const getTransformedValue = (val) => { - if (typeof val === 'string') return val.split(',').map(item => item.trim()); + // cover the case when user types comma-separated values instead multi-select + if (typeof val === 'string') { + return val.split(',').map(item => item.trim()); + } + + if (Array.isArray(val)) { + return val.map(({ value }) => value); + } - return Array.isArray(val) ? val.map(({ value }) => value) : val; + return val; }; export const sourceToMongoQuery = (source) => {