Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Dict value loses 1 trailing character on UI Launch. #561

Merged
merged 1 commit into from
Aug 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 17 additions & 20 deletions packages/zapp/console/src/components/Launch/LaunchForm/MapInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ export const MapInput = (props: InputProps) => {
setData((data) => [...data, getNewMapItem(data.length)]);
};

const updateUpperStream = () => {
const newPairs = data
const updateUpperStream = (newData: MapInputItem[]) => {
const newPairs = newData
.filter((item) => {
// we filter out delted values and items with errors or empty keys/values
return item.id !== null && !!item.key && !!item.value;
Expand All @@ -145,32 +145,29 @@ export const MapInput = (props: InputProps) => {

const onSetKey = (id: number | null, key: string) => {
if (id === null) return;
setData((data) => {
data[id].key = key;
return [...data];
});
updateUpperStream();
const newData = [...data];
newData[id].key = key;
setData([...newData]);
updateUpperStream([...newData]);
};

const onSetValue = (id: number | null, value: string) => {
if (id === null) return;
setData((data) => {
data[id].value = value;
return [...data];
});
updateUpperStream();
const newData = [...data];
newData[id].value = value;
setData([...newData]);
updateUpperStream([...newData]);
};

const onDeleteItem = (id: number | null) => {
if (id === null) return;
setData((data) => {
const dataIndex = data.findIndex((item) => item.id === id);
if (dataIndex >= 0 && dataIndex < data.length) {
data[dataIndex].id = null;
}
return [...data];
});
updateUpperStream();
const newData = [...data];
const dataIndex = newData.findIndex((item) => item.id === id);
if (dataIndex >= 0 && dataIndex < newData.length) {
newData[dataIndex].id = null;
}
setData([...newData]);
updateUpperStream([...newData]);
};

const isValid = (id: number | null, value: string) => {
Expand Down