diff --git a/client/packages/lowcoder/src/comps/comps/formComp/formComp.tsx b/client/packages/lowcoder/src/comps/comps/formComp/formComp.tsx index 84a7b7156..02ca347ff 100644 --- a/client/packages/lowcoder/src/comps/comps/formComp/formComp.tsx +++ b/client/packages/lowcoder/src/comps/comps/formComp/formComp.tsx @@ -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 ( <>
{children.resetAfterSubmit.propertyView({ label: trans("formComp.resetAfterSubmit") })}
- {isLogicMode && ( + {(useContext(EditorContext).editorModeStatus === "logic" || useContext(EditorContext).editorModeStatus === "both") && ( <>
{children.onEvent.getPropertyView()} {disabledPropertyView(children)} @@ -229,7 +225,7 @@ const FormBaseComp = (function () { )} - {isLayoutMode && ( + {(useContext(EditorContext).editorModeStatus === "layout" || useContext(EditorContext).editorModeStatus === "both") && ( <>
{children.container.getPropertyView()} @@ -237,14 +233,14 @@ const FormBaseComp = (function () { )} - {isLogicMode && ( + {(useContext(EditorContext).editorModeStatus === "logic" || useContext(EditorContext).editorModeStatus === "both") && (
{children.initialData.propertyView({ label: trans("formComp.initialData") })} {children.invalidFormMessage.propertyView({ label: trans("formComp.invalidFormMessage") })}
)} - {isLayoutMode && ( + {(useContext(EditorContext).editorModeStatus === "layout" || useContext(EditorContext).editorModeStatus === "both") && ( <>
{children.container.stylePropertyView()} @@ -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() { @@ -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; }, @@ -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; }, @@ -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( { @@ -398,6 +405,7 @@ let FormTmpComp = class extends FormBaseComp implements IForm { ) ); }); + } return ret; } case CompActionTypes.CUSTOM: @@ -548,4 +556,4 @@ export function defaultFormData(compName: string, nameGenerator: NameGenerator): showFooter: true, }, }; -} +} \ No newline at end of file diff --git a/client/packages/lowcoder/src/comps/comps/textInputComp/textInputConstants.tsx b/client/packages/lowcoder/src/comps/comps/textInputComp/textInputConstants.tsx index 97af00711..2d1761f1d 100644 --- a/client/packages/lowcoder/src/comps/comps/textInputComp/textInputConstants.tsx +++ b/client/packages/lowcoder/src/comps/comps/textInputComp/textInputConstants.tsx @@ -183,6 +183,12 @@ export const useTextInputProps = (props: RecordConstructorToView { + if (!changeRef.current) { + setLocalInputValue(inputValue); + } + }, [inputValue]); + useEffect(() => { if (!changeRef.current) return; @@ -214,6 +220,7 @@ export const useTextInputProps = (props: RecordConstructorToView pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy