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(cdk:scroll): content is blank when re-activated in keepalive mode #1505

Merged
merged 1 commit into from
Mar 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import type { VirtualScrollProps } from '../types'
import type { Ref } from 'vue'

import { computed } from 'vue'
import { computed, onActivated } from 'vue'

import { isFunction } from 'lodash-es'

Expand Down Expand Up @@ -64,5 +64,12 @@ export function useScrollPlacement(
}
}

const initScrollTop = () => {
if (holderRef.value) {
syncScrollTop(scrollTop.value, true)
}
}
onActivated(initScrollTop)

return { syncScrollTop, handleScroll }
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with a brief review

This code patch looks to be making a change to the useScrollPlacement() function. The first change is to import the onActivated hook from Vue. The second is to add the initScrollTop() function, which will sync the initial scrollTop value when the holderRef has been set. This should help prevent any initial UI issues.

Overall, the code looks to be well written and should have minimal risk of bugs. The only suggestion I have is to consider adding some unit tests for the new initScrollTop() function to ensure it works correctly.