From 39331d95b29dcc1ba87b39a97b7ca213e76e9fe9 Mon Sep 17 00:00:00 2001 From: Nikhil Nandagopal Date: Thu, 5 Nov 2020 15:46:38 +0530 Subject: [PATCH] fix for args not splitting correctly with empty values --- .../actioncreator/ActionCreator.tsx | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/app/client/src/components/editorComponents/actioncreator/ActionCreator.tsx b/app/client/src/components/editorComponents/actioncreator/ActionCreator.tsx index 4a13bd04f9..4dde0055e6 100644 --- a/app/client/src/components/editorComponents/actioncreator/ActionCreator.tsx +++ b/app/client/src/components/editorComponents/actioncreator/ActionCreator.tsx @@ -106,13 +106,21 @@ const JSToString = (js: string): string => { const argsStringToArray = (funcArgs: string): string[] => { const argsplitMatches = [...funcArgs.matchAll(FUNC_ARGS_REGEX)]; - return argsplitMatches - .map(match => { - return match[0]; - }) - .filter(arg => { - return arg !== ""; - }); + const arr: string[] = []; + let isPrevUndefined = true; + argsplitMatches.forEach(match => { + const matchVal = match[0]; + if (!matchVal || matchVal === "") { + if (isPrevUndefined) { + arr.push(matchVal); + } + isPrevUndefined = true; + } else { + isPrevUndefined = false; + arr.push(matchVal); + } + }); + return arr; }; const textSetter = (