diff --git a/.changeset/forty-cherries-sleep.md b/.changeset/forty-cherries-sleep.md new file mode 100644 index 0000000000..4fb656d37f --- /dev/null +++ b/.changeset/forty-cherries-sleep.md @@ -0,0 +1,5 @@ +--- +'@talend/react-forms': patch +--- + +fix: move skipCommas options to schema object instead of component api diff --git a/packages/forms/src/UIForm/fields/Enumeration/EnumerationWidget.js b/packages/forms/src/UIForm/fields/Enumeration/EnumerationWidget.js index c246af5a5e..1451675d86 100644 --- a/packages/forms/src/UIForm/fields/Enumeration/EnumerationWidget.js +++ b/packages/forms/src/UIForm/fields/Enumeration/EnumerationWidget.js @@ -439,7 +439,7 @@ class EnumerationForm extends React.Component { })); const formattedValue = EnumerationForm.parseStringValueToArray( value.value, - this.props.skipCommas, + this.props.schema?.skipCommas || false, ); this.props .onTrigger(event, { @@ -478,7 +478,10 @@ class EnumerationForm extends React.Component { // if the value is empty, no value update is done if (value.value && !valueExist) { - item.values = EnumerationForm.parseStringValueToArray(value.value, this.props.skipCommas); + item.values = EnumerationForm.parseStringValueToArray( + value.value, + this.props.schema?.skipCommas || false, + ); } if (valueExist) { item.error = this.props.t('ENUMERATION_WIDGET_DUPLICATION_ERROR', { @@ -711,7 +714,10 @@ class EnumerationForm extends React.Component { this.props .onTrigger(event, { trigger: { - value: EnumerationForm.parseStringValueToArray(value.value, this.props.skipCommas), + value: EnumerationForm.parseStringValueToArray( + value.value, + this.props.schema?.skipCommas || false, + ), action: ENUMERATION_ADD_ACTION, }, schema, @@ -735,7 +741,10 @@ class EnumerationForm extends React.Component { schema, value: this.state.items.concat([ { - values: EnumerationForm.parseStringValueToArray(value.value, this.props.skipCommas), + values: EnumerationForm.parseStringValueToArray( + value.value, + this.props.schema?.skipCommas || false, + ), }, ]), }; @@ -1060,7 +1069,6 @@ if (process.env.NODE_ENV !== 'production') { onTrigger: PropTypes.func.isRequired, properties: PropTypes.object, schema: PropTypes.object, - skipCommas: PropTypes.bool, t: PropTypes.func, value: PropTypes.arrayOf( PropTypes.shape({ diff --git a/packages/forms/src/UIForm/fields/Enumeration/EnumerationWidget.test.js b/packages/forms/src/UIForm/fields/Enumeration/EnumerationWidget.test.js index 659f0dfbb6..e0fc363751 100644 --- a/packages/forms/src/UIForm/fields/Enumeration/EnumerationWidget.test.js +++ b/packages/forms/src/UIForm/fields/Enumeration/EnumerationWidget.test.js @@ -245,9 +245,8 @@ describe('EnumerationWidget', () => { onChange={jest.fn()} onFinish={jest.fn()} onTrigger={onTrigger} - schema={{}} + schema={{ skipCommas: true }} properties={{ connectedMode: true }} - skipCommas />, ); @@ -258,7 +257,9 @@ describe('EnumerationWidget', () => { // then expect(onTrigger).toBeCalledWith(expect.anything(), { - schema: {}, + schema: { + skipCommas: true, + }, trigger: { action: 'ENUMERATION_ADD_ACTION', value: ['foo, tata'],