Skip to content

Commit b1c8799

Browse files
fixed query variables loses focus while typing
1 parent 343f688 commit b1c8799

File tree

3 files changed

+46
-29
lines changed

3 files changed

+46
-29
lines changed

Diff for: client/packages/lowcoder-design/src/components/keyValueList.tsx

+41-23
Original file line numberDiff line numberDiff line change
@@ -73,34 +73,52 @@ const AddBtn = styled(TacoButton)`
7373
}
7474
`;
7575

76+
const IndicatorWrapper = ({
77+
indicatorForAll,
78+
children,
79+
}: {
80+
indicatorForAll?: boolean;
81+
children: ReactNode,
82+
}) => {
83+
if (indicatorForAll) {
84+
return (
85+
<BranchDiv $type={"inline"}>
86+
{children}
87+
</BranchDiv>
88+
)
89+
}
90+
return (<>{children}</>);
91+
};
92+
7693
export const KeyValueList = (props: {
7794
list: ReactNode[];
7895
onAdd: () => void;
7996
onDelete: (item: ReactNode, index: number) => void;
8097
isStatic?: boolean;
8198
indicatorForAll?: boolean;
8299
}) => {
83-
let IndicatorWrapper = ({children}: any) => (<>{children}</>);
84-
if(props.indicatorForAll) IndicatorWrapper = BranchDiv;
85-
return <>
86-
{props.list.map((item, index) => (
87-
<IndicatorWrapper $type={"inline"} key={index}>
88-
<KeyValueListItem key={index /* FIXME: find a proper key instead of `index` */}>
89-
{item}
90-
{!props.isStatic &&
91-
<DelIcon
92-
onClick={() => props.list.length > 1 && props.onDelete(item, index)}
93-
$forbidden={props.list.length === 1}
94-
/>
95-
}
96-
</KeyValueListItem>
97-
</IndicatorWrapper>
98-
))}
99-
{!props.isStatic &&
100-
<AddBtn onClick={props.onAdd}>
101-
<AddIcon />
102-
{trans("addItem")}
103-
</AddBtn>
104-
}
105-
</>
100+
return (
101+
<>
102+
{props.list.map((item, index) => (
103+
<IndicatorWrapper key={index}>
104+
<KeyValueListItem key={index /* FIXME: find a proper key instead of `index` */}>
105+
{item}
106+
{!props.isStatic &&
107+
<DelIcon
108+
onClick={() => props.list.length > 1 && props.onDelete(item, index)}
109+
$forbidden={props.list.length === 1}
110+
/>
111+
}
112+
</KeyValueListItem>
113+
</IndicatorWrapper>
114+
))}
115+
{!props.isStatic && (
116+
<AddBtn onClick={props.onAdd}>
117+
<AddIcon />
118+
{trans("addItem")}
119+
</AddBtn>
120+
121+
)}
122+
</>
123+
)
106124
};

Diff for: client/packages/lowcoder/src/comps/queries/queryComp.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ export const QueryComp = withExposingConfigs(QueryCompTmp, [
664664
new NameConfig("runTime", trans("query.runTimeExportDesc")),
665665
new NameConfig("latestEndTime", trans("query.latestEndTimeExportDesc")),
666666
new DepsConfig(
667-
"variable",
667+
"variables",
668668
(children: any) => {
669669
return {data: children.variables.children.variables.node()};
670670
},
@@ -673,8 +673,8 @@ export const QueryComp = withExposingConfigs(QueryCompTmp, [
673673
return undefined;
674674
}
675675
const newNode = Object.values(input.data)
676-
.filter((kvNode: any) => kvNode.key.text.value)
677-
.map((kvNode: any) => ({[kvNode.key.text.value]: kvNode.value.text.value}))
676+
.filter((kvNode: any) => kvNode.key.value)
677+
.map((kvNode: any) => ({[kvNode.key.value]: kvNode.value.value}))
678678
.reduce((prev, obj) => ({...prev, ...obj}), {});
679679
return newNode;
680680
},

Diff for: client/packages/lowcoder/src/comps/queries/queryComp/variablesComp.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ import { keyValueListControl } from "../../controls/keyValueListControl";
33

44
export const VariablesComp = new MultiCompBuilder(
55
{
6-
variables: withDefault(keyValueListControl(), [{ key: "", value: "" }]),
6+
variables: withDefault(keyValueListControl(false, [], "string"), [{ key: "", value: "" }]),
77
},
8-
(props) =>
9-
props.variables
8+
(props) => props //props.variables
109
)
1110
.setPropertyViewFn((children) => (
1211
<>

0 commit comments

Comments
 (0)