Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Form child elements not populating#1876

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall 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
34 changes: 21 additions & 13 deletionsclient/packages/lowcoder/src/comps/comps/formComp/formComp.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -208,17 +208,13 @@ const FormBaseComp = (function () {
);
})
.setPropertyViewFn((children) => {
const editorContext = useContext(EditorContext);
const isLogicMode = editorContext.editorModeStatus === "logic" || editorContext.editorModeStatus === "both";
const isLayoutMode = editorContext.editorModeStatus === "layout" || editorContext.editorModeStatus === "both";

return (
<>
<Section name={sectionNames.basic}>
{children.resetAfterSubmit.propertyView({ label: trans("formComp.resetAfterSubmit") })}
</Section>

{isLogicMode && (
{(useContext(EditorContext).editorModeStatus === "logic" || useContext(EditorContext).editorModeStatus === "both") && (
<><Section name={sectionNames.interaction}>
{children.onEvent.getPropertyView()}
{disabledPropertyView(children)}
Expand All@@ -229,22 +225,22 @@ const FormBaseComp = (function () {
</>
)}

{isLayoutMode && (
{(useContext(EditorContext).editorModeStatus === "layout" || useContext(EditorContext).editorModeStatus === "both") && (
<>
<Section name={sectionNames.layout}>
{children.container.getPropertyView()}
</Section>
</>
)}

{isLogicMode && (
{(useContext(EditorContext).editorModeStatus === "logic" || useContext(EditorContext).editorModeStatus === "both") && (
<Section name={sectionNames.advanced}>
{children.initialData.propertyView({ label: trans("formComp.initialData") })}
{children.invalidFormMessage.propertyView({ label: trans("formComp.invalidFormMessage") })}
</Section>
)}

{isLayoutMode && (
{(useContext(EditorContext).editorModeStatus === "layout" || useContext(EditorContext).editorModeStatus === "both") && (
<>
<Section name={sectionNames.style}>
{children.container.stylePropertyView()}
Expand DownExpand Up@@ -289,7 +285,8 @@ let FormTmpComp = class extends FormBaseComp implements IForm {
}
traverseFormItems(consumer: (item: GridItemComp) => boolean) {
return traverseCompTree(this.getCompTree(), (item) => {
return item.children.comp.children.formDataKey ? consumer(item as GridItemComp) : true;
const hasFormDataKey = item.children.comp.children.hasOwnProperty("formDataKey");
return hasFormDataKey ? consumer(item as GridItemComp) : true;
});
}
validateFormItems() {
Expand DownExpand Up@@ -333,12 +330,19 @@ let FormTmpComp = class extends FormBaseComp implements IForm {
// For the properties, first find in data, then initialData, subcomponent default value (resetValue), empty value (clearValue)
const newData = { ...(initialData ?? this.children.initialData.getView()), ...data };

// Only proceed if we have data to set
if (!Object.keys(newData).length) {
return Promise.resolve();
}

return this.runMethodOfItems(
{
name: "setValue",
getParams: (t) => {
// use component name when formDataKey is empty
const key = t.children.comp.children.formDataKey?.getView() || t.children.name.getView();
const formDataKey = t.children.comp.children.formDataKey?.getView();
const componentName = t.children.name.getView();
const key = formDataKey || componentName;
const value = newData[key];
return value !== undefined ? [value as EvalParamType] : undefined;
},
Expand All@@ -347,7 +351,9 @@ let FormTmpComp = class extends FormBaseComp implements IForm {
name: "setRange",
getParams: (t) => {
// use component name when formDataKey is empty
const key = t.children.comp.children.formDataKey?.getView() || t.children.name.getView();
const formDataKey = t.children.comp.children.formDataKey?.getView();
const componentName = t.children.name.getView();
const key = formDataKey || componentName;
const value = newData[key] ? newData[key] : undefined;
return value !== undefined ? [value as EvalParamType] : undefined;
},
Expand DownExpand Up@@ -387,7 +393,8 @@ let FormTmpComp = class extends FormBaseComp implements IForm {
case CompActionTypes.UPDATE_NODES_V2: {
const ret = super.reduce(action);
// When the initial value changes, update the form
requestAnimationFrame(() => {
if (action.value["initialData"] !== undefined) {
queueMicrotask(() => {
this.dispatch(
customAction<SetDataAction>(
{
Expand All@@ -398,6 +405,7 @@ let FormTmpComp = class extends FormBaseComp implements IForm {
)
);
});
}
return ret;
}
case CompActionTypes.CUSTOM:
Expand DownExpand Up@@ -548,4 +556,4 @@ export function defaultFormData(compName: string, nameGenerator: NameGenerator):
showFooter: true,
},
};
}
}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -183,6 +183,12 @@ export const useTextInputProps = (props: RecordConstructorToView<typeof textInpu
props.value.onChange(defaultValue)
}, [defaultValue]);

useEffect(() => {
if (!changeRef.current) {
setLocalInputValue(inputValue);
}
}, [inputValue]);

useEffect(() => {
if (!changeRef.current) return;

Expand DownExpand Up@@ -214,6 +220,7 @@ export const useTextInputProps = (props: RecordConstructorToView<typeof textInpu
debounce(function (value: string, valueCtx: any) {
propsRef.current.value.onChange(value);
propsRef.current.onEvent("change");
changeRef.current = false; // Reset after commit
}, 1000)
);

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp