-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 ordering of pmc after subtree update. #2388
Conversation
0a481c0
to
524475b
Compare
paths.push(item); | ||
} else { | ||
objs[keyStr] = insert(index, item, paths); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't quite put my finger on it, but I think there's a situation here where either the index you end up inserting at isn't what it should be anymore, or the item looks new - so gets put at the end instead of in the middle - but it's just a modification of the old item.
What I think we implicitly really want is for objs[keystr]
to wind up sorted by path (ie in increasing value of the first item in the path that differs between any two elements). And if I'm reading this correctly, the only case in which this matters is when we saved some of the old paths (line 35 above) and added more items with the same keyStr
here.
So perhaps we could do something like save a record of which keyStr
's (oldKeys
) we pre-populated above, then when we get here if we find a keyStr
in that set we insert the new item in the list before the first item with a later path, if any; otherwise we push the new item on the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure there is way currently to trigger the situation you are describing, the issue this fix is that the fix for pattern matching callback with component as props reevaluate paths of the parent of the prop and thus was updating the existing pmc indexes. Otherwise currently the subtree is updated entirely from the callback and evaluated properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK - I can't construct one either. Maybe partial props will expose something new... we'll see. Just keep this in mind as we go along in case any new bug reports pop up!
# Conflicts: # CHANGELOG.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💃 looks good, and great test!
Fix #2368