-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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(Suspense): correctly update the transition anchor point #9999
Conversation
Size ReportBundles
Usages
|
It works as expected in the playground, but the result is incorrect in e2e. I may need some guidance. |
This comment was marked as outdated.
This comment was marked as outdated.
Did you forget to run |
case 1:
via #9999 (comment) |
case2:
|
The test results of e2e on my window machine, mac, and vue ci may be inconsistent every time I run it. |
I think we only need to obtain an anchor once and cache it. No matter how the branch is switched internally, the anchor will not change. Like this: if (activeBranch) {
// if the fallback tree was mounted, it may have been moved
// as part of a parent suspense. get the latest anchor for insertion
- anchor = next(activeBranch)
+ anchor = suspense.__anchor !== undefined
+ ? suspense.__anchor
+ : (suspense.__anchor = next(activeBranch))
unmount(activeBranch, parentComponent, suspense, true)
} activeBranch!.transition!.afterLeave = () => {
if (pendingId === suspense.pendingId) {
move(
pendingBranch!,
container,
- next(activeBranch!),
+ anchor,
MoveType.ENTER,
)
queuePostFlushCb(effects)
}
} |
Good idea, already modified |
I took a closer look, and caching the anchor may not work. If the anchor is uninstalled, there may still be problems with rendering. 😂😂😂 |
So for special processing like I did before, what about just doing the cache anchor in case1 and case2? |
I took a deep look at #8105 and found the cause for the error is that the anchor is inside the hiddenContainer, so the anchor is not valid. We just need to get the latest anchor during try // 1
move(
pendingBranch!,
container,
anchor === suspense.anchor
? next(activeBranch!)
: anchor,
MoveType.ENTER,
)
// 2
if (activeBranch) {
// if the fallback tree was mounted, it may have been moved
// as part of a parent suspense. get the latest anchor for insertion
// #8105 if `delayEnter` is true, it means that the mounting of `activeBranch` will be delayed.
// if the branch switches before transition completes, both `activeBranch` and `pendingBranch` may coexist
// in the `hiddenContainer`. This could result in `next(activeBranch!)` obtaining
// an incorrect anchor (got `pendingBranch.el`).
// Therefore, after the mounting of activeBranch is completed,
// it is necessary to get the latest anchor.
if(parentNode(activeBranch.el!) !== suspense.hiddenContainer){
anchor = next(activeBranch)
}
unmount(activeBranch, parentComponent, suspense, true)
} |
close: #9996