diff --git a/Composer/packages/adaptive-form/src/components/fields/ArrayField.tsx b/Composer/packages/adaptive-form/src/components/fields/ArrayField.tsx index d7a6c6f244..fee38f9bc9 100644 --- a/Composer/packages/adaptive-form/src/components/fields/ArrayField.tsx +++ b/Composer/packages/adaptive-form/src/components/fields/ArrayField.tsx @@ -3,7 +3,6 @@ /** @jsx jsx */ import { jsx } from '@emotion/core'; import React, { useState } from 'react'; -import { TextField } from 'office-ui-fabric-react/lib/TextField'; import { IconButton } from 'office-ui-fabric-react/lib/Button'; import { TooltipHost } from 'office-ui-fabric-react/lib/Tooltip'; import { SharedColors, NeutralColors, FontSizes } from '@uifabric/fluent-theme'; @@ -16,6 +15,7 @@ import { FieldLabel } from '../FieldLabel'; import { arrayField } from './styles'; import { ArrayFieldItem } from './ArrayFieldItem'; import { UnsupportedField } from './UnsupportedField'; +import { WrappedTextField } from './WrappedTextField'; const ArrayField: React.FC> = (props) => { const { @@ -79,7 +79,7 @@ const ArrayField: React.FC> = (props) => {
- { fontSize?: string; styles?: Partial; @@ -64,7 +66,7 @@ const EditableField: React.FC = (props) => { onMouseEnter={() => setEditing(true)} onMouseLeave={() => !hasFocus && setEditing(false)} > - = (props) => { const { id, value = '', onChange, disabled, placeholder, readonly, error } = props; @@ -24,7 +24,7 @@ const ExpressionEditor: React.FC = (props) => { onChange={onChange} > {(textFieldValue, onValueChanged, onKeyDownTextField, onKeyUpTextField, onClickTextField) => ( - > = function IntellisenseField(props) { const { id, value = '', onChange, label, description, uiOptions, required } = props; @@ -24,7 +25,7 @@ export const IntellisenseField: React.FC> = function Intellis onChange={onChange} > {(textFieldValue, onValueChanged, onKeyDownTextField, onKeyUpTextField, onClickTextField) => ( - , propertyName: string): string | undefined => { const { uiOptions } = props; @@ -152,7 +153,7 @@ const ObjectArrayField: React.FC> = (props) => { if (typeof property === 'string') { return (
- > = function ObjectField(props) { const { schema, uiOptions, depth, value, label, ...rest } = props; + const valueRef = useRef(value); + valueRef.current = value; if (!schema) { return null; @@ -16,7 +18,7 @@ const ObjectField: React.FC> = function ObjectField(props) { const newDepth = depth + 1; const handleChange = (field: string) => (data: any) => { - const newData = { ...value }; + const newData = { ...valueRef.current }; if (typeof data === 'undefined' || (typeof data === 'string' && data.length === 0)) { delete newData[field]; diff --git a/Composer/packages/adaptive-form/src/components/fields/StringField.tsx b/Composer/packages/adaptive-form/src/components/fields/StringField.tsx index 2ffbbc4bce..5c569fb5ea 100644 --- a/Composer/packages/adaptive-form/src/components/fields/StringField.tsx +++ b/Composer/packages/adaptive-form/src/components/fields/StringField.tsx @@ -4,11 +4,12 @@ import React from 'react'; import { FieldProps } from '@bfc/extension-client'; import { NeutralColors } from '@uifabric/fluent-theme'; -import { TextField } from 'office-ui-fabric-react/lib/TextField'; import formatMessage from 'format-message'; import { FieldLabel } from '../FieldLabel'; +import { WrappedTextField } from './WrappedTextField'; + export const borderStyles = (transparentBorder: boolean, error: boolean) => transparentBorder ? { @@ -63,7 +64,7 @@ export const StringField: React.FC> = function StringField(pr return ( <> - { + shouldComponentUpdate(nextProps: ITextFieldProps) { + if (this.props.value === nextProps.value) { + return false; + } + + return true; + } + + render() { + return ; + } +}