From 0509f5224fc64f06115853aae31dd4cb8a0fcba3 Mon Sep 17 00:00:00 2001 From: Vesa Luusua Date: Wed, 28 Aug 2019 21:33:02 +0300 Subject: [PATCH 1/2] Fix FieldBirthdayInput: valueFromForm prop didn't work anymore --- .../FieldBirthdayInput.example.js | 19 ++++++++++++++++++- .../FieldBirthdayInput/FieldBirthdayInput.js | 2 ++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/components/FieldBirthdayInput/FieldBirthdayInput.example.js b/src/components/FieldBirthdayInput/FieldBirthdayInput.example.js index 21b8ba5a..a132a4a7 100644 --- a/src/components/FieldBirthdayInput/FieldBirthdayInput.example.js +++ b/src/components/FieldBirthdayInput/FieldBirthdayInput.example.js @@ -28,7 +28,7 @@ const FormComponent = props => ( name="birthday" label="Date of birth" format={identity} - valueFromForm={values.birthDate} + valueFromForm={values.birthday} validate={validators.composeValidators(required, minAgeRequired)} /> @@ -52,3 +52,20 @@ export const Empty = { }, group: 'custom inputs', }; + +export const WithInitialValue = { + component: FormComponent, + props: { + initialValues: { birthday: new Date('1982-03-01') }, + onChange: formState => { + const birthday = formState.values.birthday; + if (birthday && formState.dirty) { + console.log('birthday changed to:', birthday); + } + }, + onSubmit: values => { + console.log('BirthdayInput.Form submitted values:', values); + }, + }, + group: 'custom inputs', +}; diff --git a/src/components/FieldBirthdayInput/FieldBirthdayInput.js b/src/components/FieldBirthdayInput/FieldBirthdayInput.js index 96896483..eceea3e1 100644 --- a/src/components/FieldBirthdayInput/FieldBirthdayInput.js +++ b/src/components/FieldBirthdayInput/FieldBirthdayInput.js @@ -259,6 +259,7 @@ const FieldBirthdayInputComponent = props => { disabled, input, meta, + valueFromForm, } = props; const { valid, invalid, touched, error } = meta; @@ -287,6 +288,7 @@ const FieldBirthdayInputComponent = props => { monthLabel, yearLabel, disabled, + valueFromForm, ...input, }; const classes = classNames(rootClassName || css.fieldRoot, className); From a3fd95797123256ec42e94cd4d6adb2adf50845e Mon Sep 17 00:00:00 2001 From: Vesa Luusua Date: Wed, 28 Aug 2019 21:36:34 +0300 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf6fea21..00a0be83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ way to update this template, but currently, we follow a pattern: ## Upcoming version 2019-XX-XX +- [fix] Bug fix: valueFromForm prop wasn't passed through different subcomponents. + [#1182](https://github.com/sharetribe/flex-template-web/pull/1182) - [add] Update German and French translations. [#1184](https://github.com/sharetribe/flex-template-web/pull/1184) - [change] Migrate from `react-helmet` to `react-helmet-async`