Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix async/submit errors getter for nested fields #3755

Merged
merged 1 commit into from
Jan 18, 2018
Merged

Fix async/submit errors getter for nested fields #3755

merged 1 commit into from
Jan 18, 2018

Conversation

xcrzx
Copy link
Contributor

@xcrzx xcrzx commented Jan 15, 2018

asyncErrors & submitErrors are flat key-value objects: { 'field.a.b.c': 'error' }, so we should escape field name in order to get data from it.

@codecov-io
Copy link

codecov-io commented Jan 15, 2018

Codecov Report

Merging #3755 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #3755   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files          70      70           
  Lines        1578    1578           
======================================
  Hits         1578    1578
Impacted Files Coverage Δ
src/ConnectedField.js 100% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 90fdd65...d16f1e2. Read the comment docs.

@erikras
Copy link
Member

erikras commented Jan 16, 2018

Doesn't this work, too, and is better?

asyncError: getIn(formState.asyncErrors, name),

@xcrzx
Copy link
Contributor Author

xcrzx commented Jan 16, 2018

Unfortunately not.

const formState = {
    asyncErrors: {
        'a.b.c': 'Error message',
    }
};

const name = 'a.b.c';

getIn(formState, `asyncErrors['${name}']`); // 'Error message'
getIn(formState.asyncErrors, name); // undefined

Following code getIn(formState.asyncErrors, 'a.b.c') is trying to access formState.asyncErrors.a.b.c while actually we need formState.asyncErrors['a.b.c']

@erikras erikras merged commit 6357a5d into redux-form:master Jan 18, 2018
@erikras
Copy link
Member

erikras commented Jan 18, 2018

Published in v7.2.1.

@sergeyfedotov
Copy link

It's a breaking change. Before v7.2.1 only nested error object could be used.

@dagstuan
Copy link
Contributor

This should have been released as 8.0.0 as this is a breaking change.

@erikras
Copy link
Member

erikras commented Feb 1, 2018

Apologies for this accidental breaking change... it should be rolled back (unbroken).

erikras added a commit that referenced this pull request Feb 1, 2018
…components, since they were changed for Fields in #3755 (#3802)"

This reverts commit 4b4e994.
erikras added a commit that referenced this pull request Feb 1, 2018
…Array and Fields." (#3804)

* Revert "Fix for formValues not reacting to props change (#3794)"

This reverts commit 701fdc0.

* Revert "Fix for double INITIALIZE happening on first mount (#3797)"

This reverts commit 5c13be0.

* Revert "Fixes asyncErrors and submitErrors for FieldArray and Fields components, since they were changed for Fields in #3755 (#3802)"

This reverts commit 4b4e994.
erikras added a commit that referenced this pull request Feb 1, 2018
erikras added a commit that referenced this pull request Feb 1, 2018
* Reverted breaking change in #3755

* Fixed test error
@erikras
Copy link
Member

erikras commented Feb 1, 2018

Reverted this change in v7.2.2, as it broke several things. Let's discuss how to accomplish what you need to.

@lock
Copy link

lock bot commented Jun 1, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants