From 73c62d04af425f098c1c8f31c99200c9c896ca45 Mon Sep 17 00:00:00 2001 From: RazvanHrestic Date: Wed, 19 Nov 2025 13:30:27 +0100 Subject: [PATCH] Removed obsolete componentDidUpdate in DynamicField and changed onBlur --- .../dynamicForm/dynamicField/DynamicField.tsx | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/controls/dynamicForm/dynamicField/DynamicField.tsx b/src/controls/dynamicForm/dynamicField/DynamicField.tsx index b5d8f00a5..8ca2ede28 100644 --- a/src/controls/dynamicForm/dynamicField/DynamicField.tsx +++ b/src/controls/dynamicForm/dynamicField/DynamicField.tsx @@ -43,18 +43,12 @@ export class DynamicFieldBase extends React.Component; - public componentDidUpdate(): void { - if ((this.props.defaultValue === "" || this.props.defaultValue === null) && this.state.changedValue === null) { - this.setState({ changedValue: "" }); - } - } - public render(): JSX.Element { try { const theme = getFluentUIThemeOrDefault(); const styles = (this._classNames = getClassNames(this.props.styles, { theme: theme, - required:this.props.required + required: this.props.required })); return (
@@ -115,7 +109,7 @@ export class DynamicFieldBase extends React.Component{label}; const errorText = this.props.validationErrorMessage || this.getRequiredErrorText(); const errorTextEl = {errorText}; @@ -222,7 +216,7 @@ export class DynamicFieldBase extends React.Component { this.onChange(option, true); }} disabled={disabled} - />; + />; } return
@@ -233,7 +227,7 @@ export class DynamicFieldBase extends React.Component; -} + } case 'MultiChoice': return
@@ -608,7 +602,7 @@ export class DynamicFieldBase extends React.Component { this.onChange(newValue, true); }} />
- : + :
{ - if (this.state.changedValue === null && this.props.defaultValue === "") { - this.setState({ changedValue: "" }); + // If we have a changedValue, or the user has cleared out a field + if (this.state.changedValue || this.state.changedValue === "") { + // Notify DynamicForm and fire its onChange event + this.props.onChanged(this.props.columnInternalName, this.state.changedValue, true); } - this.props.onChanged(this.props.columnInternalName, this.state.changedValue, true); } private getRequiredErrorText = (): string => { @@ -725,12 +720,12 @@ export class DynamicFieldBase extends React.Component