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

Immutable setIn is broken with more than 32 elements in an array. #3803

Merged
merged 1 commit into from
Feb 1, 2018

Conversation

dagstuan
Copy link
Contributor

@dagstuan dagstuan commented Feb 1, 2018

This PR fixes an issue introduced in #3692 where the mergeLists method in setIn.js for immutable.js was updated due to mergeDeepWith being removed as a List function in immutable.js@4.0.0-rc.5. Unfortunately this change introduced and error in which arrays with more than 32 elements were behaving unexpectedly since the new way of doing it didnt use ordered maps, instead just calls toMap(), which causes the merging to lose order with more than 32 elements due to optimizations in immutable.js. After 4.0.0-rc.5, the mergeDeepWith-method is exported as a global export instead of being attatched to Map, and List. This PR uses the global export version 4.x and uses the old way of merging for users with 3.x. I also added a test with long arrays for immutable setIn.

This PR should fix #3791

@erikras @gustavohenke can this be merged fast? Its pretty important since all long FieldArrays are currently broken.

… elements would yield unexpected behavior
@dagstuan dagstuan changed the title Immutable SetIn is broken with more than 32 elements. Immutable setIn is broken with more than 32 elements. Feb 1, 2018
@codecov-io
Copy link

codecov-io commented Feb 1, 2018

Codecov Report

Merging #3803 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #3803   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files          70      70           
  Lines        1593    1597    +4     
======================================
+ Hits         1593    1597    +4
Impacted Files Coverage Δ
src/structure/immutable/setIn.js 100% <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 216bffa...bfac461. Read the comment docs.

@dagstuan
Copy link
Contributor Author

dagstuan commented Feb 1, 2018

@erikras is it possible to allow the testfile for setIn to be longer than 250 lines so codeclimate will accept it? Or should I move the test to a separate file?

@dagstuan dagstuan changed the title Immutable setIn is broken with more than 32 elements. Immutable setIn is broken with more than 32 elements in an array. Feb 1, 2018
@erikras
Copy link
Member

erikras commented Feb 1, 2018

Code Climate is supposed to be ignoring *.spec.js, but their API changed.

@erikras erikras merged commit 95439a1 into redux-form:master Feb 1, 2018
@cristian-sima
Copy link

you are a the God. I just encored this problem and I was writing an issue :D waiting for solution

@dagstuan dagstuan deleted the fixLongImmutableSetIn branch February 1, 2018 15:58
@erikras
Copy link
Member

erikras commented Feb 1, 2018

Published in v7.2.2.

@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.

[Bug]Changes to items in FieldArray cause whole list of items to update
4 participants