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 ordering of pmc after subtree update. #2388

Merged
merged 4 commits into from
Jan 23, 2023
Merged

Fix ordering of pmc after subtree update. #2388

merged 4 commits into from
Jan 23, 2023

Conversation

T4rk1n
Copy link
Contributor

@T4rk1n T4rk1n commented Jan 16, 2023

Fix #2368

@T4rk1n T4rk1n force-pushed the fix-2368 branch 2 times, most recently from 0a481c0 to 524475b Compare January 16, 2023 20:58
paths.push(item);
} else {
objs[keyStr] = insert(index, item, paths);
}
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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
Copy link
Collaborator

@alexcjohnson alexcjohnson left a 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!

@T4rk1n T4rk1n merged commit 443aae3 into dev Jan 23, 2023
@T4rk1n T4rk1n deleted the fix-2368 branch January 23, 2023 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Pattern-Matching Callbacks ALL inconsistent order in dash 2.7.1
2 participants