Skip to content

Fix freeze when scrolling is cancelled during overscroll #1928

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

Merged
merged 2 commits into from
Mar 21, 2025

Conversation

ASalavei
Copy link

Reset the overscroll effect when no ongoing animation or interaction is applied.

Fixes https://youtrack.jetbrains.com/issue/CMP-7099/iOS-Content-in-a-scrollable-container-becomes-non-focusable-after-calling-focusManager.clearFocus

Release Notes

Fixes - iOS

  • Fix freeze where scrolling was cancelled but the overscroll effect was not completed

Comment on lines -129 to +134
private var overscrollOffset: Offset by mutableStateOf(Offset.Zero)
private var overscrollOffsetState = mutableStateOf(Offset.Zero)
private var overscrollOffset: Offset
Copy link
Member

Choose a reason for hiding this comment

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

It will probably be clearer to use an idiomatic approach here:

snapshotFlow { overscrollOffset }
    .collect { /* your on change logic */ }

Copy link
Author

Choose a reason for hiding this comment

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

It requires some coroutineContext - but as far as I figured out, it's hard to find one on ini state

) {
if (pass == PointerEventPass.Final) {
if (pointerEvent.type == PointerEventType.Press) {
pointersDown++
Copy link
Member

Choose a reason for hiding this comment

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

Should we increment on Initial event pass?

Copy link
Author

Choose a reason for hiding this comment

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

Since it only triggers recomposition, any phase is sufficient.

override fun onRemeasured(size: IntSize) = onNodeRemeasured(size)

var pointersDown by mutableStateOf(0)
Copy link
Member

Choose a reason for hiding this comment

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

Why is it a state? Isn't draw called without it?

Copy link
Author

Choose a reason for hiding this comment

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

The change we're looking for has to be triggered by the touch up gesture. If it's not a state - it won't work.

@ASalavei ASalavei requested a review from MatkovIvan March 19, 2025 18:53
@ASalavei ASalavei merged commit 20068c4 into jb-main Mar 21, 2025
8 checks passed
@ASalavei ASalavei deleted the andrei.salavei/overscroll-freeze branch March 21, 2025 10:22
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.

3 participants