Skip to content

Commit

Permalink
chore: input-table 支持单元格为容器时内部放表单项也参与校验 Close: baidu#9756 (baidu#9757)
Browse files Browse the repository at this point in the history
  • Loading branch information
2betop committed Mar 14, 2024
1 parent 8aa7d73 commit 6d4ada1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion packages/amis-core/src/renderers/wrapControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export interface ControlOutterProps extends RendererProps {
changePristine?: boolean
) => void;
formItemDispatchEvent: (type: string, data: any) => void;
formItemRef?: (control: any) => void;
}

export interface ControlProps {
Expand Down Expand Up @@ -541,7 +542,12 @@ export function wrapControl<
}

controlRef(control: any) {
const {addHook, removeHook, formStore: form} = this.props;
const {
addHook,
removeHook,
formStore: form,
formItemRef
} = this.props;

// 因为 control 有可能被 n 层 hoc 包裹。
while (control && control.getWrappedInstance) {
Expand Down Expand Up @@ -570,6 +576,7 @@ export function wrapControl<
this.hook = undefined;
}

formItemRef?.(control);
// 注册到 Scoped 上
const originRef = this.control;
this.control = control;
Expand Down
4 changes: 2 additions & 2 deletions packages/amis/src/renderers/QuickEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ export const HocQuickEdit =
value: getPropValue(this.props) ?? '',
onChange: this.handleFormItemChange,
onBulkChange: this.handleBulkChange,
ref: this.formItemRef,
formItemRef: this.formItemRef,
defaultStatic: false
});
}
Expand Down Expand Up @@ -652,7 +652,7 @@ export const HocQuickEdit =
// 此处的readOnly会导致组件值无法传递出去,如 value: "${a + b}" 这样的 value 变化需要同步到数据域
// || readOnly
) {
return <Component {...this.props} />;
return <Component {...this.props} formItemRef={this.formItemRef} />;
}

if (
Expand Down

0 comments on commit 6d4ada1

Please sign in to comment.