diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/MouseWheelScrollable.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/MouseWheelScrollable.kt index def9ecb1352c2..12d6f33fd9f9e 100644 --- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/MouseWheelScrollable.kt +++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/MouseWheelScrollable.kt @@ -180,7 +180,7 @@ private class AnimatedMouseWheelScrollPhysics( } return with(scrollingLogic) { val delta = scrollDelta.reverseIfNeeded().toFloat() - if (canConsumeDelta(delta)) { + if (delta != 0f && canConsumeDelta(delta)) { if (mouseWheelScrollConfig.isPreciseWheelScroll(pointerEvent)) { // In case of high-resolution wheel, such as a freely rotating wheel with no notches // or trackpads, delta should apply directly without any delays. diff --git a/compose/foundation/foundation/src/skikoTest/kotlin/androidx/compose/foundation/copyPasteAndroidTests/ScrollableTest.kt b/compose/foundation/foundation/src/skikoTest/kotlin/androidx/compose/foundation/copyPasteAndroidTests/ScrollableTest.kt index ab55ac9addcfe..7231fbbc12666 100644 --- a/compose/foundation/foundation/src/skikoTest/kotlin/androidx/compose/foundation/copyPasteAndroidTests/ScrollableTest.kt +++ b/compose/foundation/foundation/src/skikoTest/kotlin/androidx/compose/foundation/copyPasteAndroidTests/ScrollableTest.kt @@ -768,17 +768,19 @@ class ScrollableTest { @OptIn(ExperimentalTestApi::class) @Test - fun scrollable_nestedScroll_disabledForMouseWheel() = runSkikoComposeUiTest { + fun scrollable_nestedScroll_childPartialConsumptionForMouseWheel() = runSkikoComposeUiTest { var innerDrag = 0f var outerDrag = 0f val outerState = ScrollableState( consumeScrollDelta = { + // Since the child has already consumed half, the parent will consume the rest. outerDrag += it it } ) val innerState = ScrollableState( consumeScrollDelta = { + // Child consumes half, leaving the rest for the parent to consume. innerDrag += it / 2 it / 2 } @@ -812,7 +814,10 @@ class ScrollableTest { } runOnIdle { assertThat(innerDrag).isGreaterThan(0f) - assertThat(outerDrag).isEqualTo(0f) + assertThat(outerDrag).isGreaterThan(0f) + // Since child (inner) consumes half of the scroll, the parent (outer) consumes the + // remainder (which is half as well), so they will be equal. + assertThat(innerDrag).isEqualTo(outerDrag) } }