Skip to content

Commit

Permalink
fix(Flow): set value as string if select is not multiple
Browse files Browse the repository at this point in the history
  • Loading branch information
MEsteves22 authored and plagoa committed Nov 24, 2023
1 parent ad92d03 commit 4df263e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions app/src/pages/Flow/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export const nodes = [
data: {
title: "Number of customers",
unit: "",
measure: ["Customer"],
aggregation: ["distinct"],
measure: "Customer",
aggregation: "distinct",
},
type: "kpi",
},
Expand All @@ -68,8 +68,8 @@ export const nodes = [
data: {
title: "Number of products",
unit: "",
measure: ["Product"],
aggregation: ["distinct"],
measure: "Product",
aggregation: "distinct",
},
type: "kpi",
},
Expand Down Expand Up @@ -110,8 +110,8 @@ export const nodes = [
data: {
title: "Total of sales",
unit: "$",
measure: ["Sales"],
aggregation: ["sum"],
measure: "Sales",
aggregation: "sum",
},
type: "kpi",
},
Expand Down Expand Up @@ -142,7 +142,7 @@ export const nodes = [
position: { x: 182, y: 786 },
data: {
title: "Sales per territory",
measure: ["EMEA"],
measure: "EMEA",
},
type: "table",
},
Expand Down
8 changes: 4 additions & 4 deletions packages/lab/src/components/Flow/Node/Parameters/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ const Select = ({ nodeId, param, data }: SelectProps) => {

const newOpts = Array.isArray(item)
? item.map((x) => x.label as string)
: item?.label
? [item.label as string]
: undefined;
: (item?.label as string) ?? undefined;

const newNodes = nodes.map((node) => {
if (node.id === nodeId) {
Expand All @@ -39,7 +37,9 @@ const Select = ({ nodeId, param, data }: SelectProps) => {
});

reactFlowInstance.setNodes(newNodes);
setOpts(newOpts);
setOpts(
newOpts ? (Array.isArray(newOpts) ? newOpts : [newOpts]) : undefined
);
};

return (
Expand Down

0 comments on commit 4df263e

Please sign in to comment.