From 7adf48d0b9c4f6cb54f88000151a2b24425d5cba Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 17 Oct 2022 20:30:14 +0800 Subject: [PATCH] refactor(nc-gui): use set for calculating unique values --- packages/nc-gui/utils/parsers/parserHelpers.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/nc-gui/utils/parsers/parserHelpers.ts b/packages/nc-gui/utils/parsers/parserHelpers.ts index ce07e8494d..fbcf69bf37 100644 --- a/packages/nc-gui/utils/parsers/parserHelpers.ts +++ b/packages/nc-gui/utils/parsers/parserHelpers.ts @@ -63,9 +63,9 @@ export const extractMultiOrSingleSelectProps = (colData: []) => { .split(/\s*,\s*/) : [], ) - const uniqueVals = (flattenedVals = flattenedVals.filter( - (v, i, arr) => i === arr.findIndex((v1) => v.toLowerCase() === v1.toLowerCase()), - )) + + const uniqueVals = [...new Set(flattenedVals.map((v: any) => v.toString().trim().toLowerCase()))] + if (uniqueVals.length > maxSelectOptionsAllowed) { // too many options are detected, convert the column to SingleLineText instead colProps.uidt = UITypes.SingleLineText