Status Update
Comments
na...@gmail.com <na...@gmail.com> #2
Thanks! This looks like a bug, thank you for reporting!
si...@google.com <si...@google.com>
si...@google.com <si...@google.com>
so...@google.com <so...@google.com> #3
Dragging up to 10% or between 50% and 90% will cause it to snap back to the start anchor.
Dragging between 10% and 50% or past 90% will cause it to snap to the end anchor.
na...@gmail.com <na...@gmail.com> #4
Project: platform/frameworks/support
Branch: androidx-main
Author: Jossi Wolf <
Link:
Update AnchoredDraggable target calculation logic
Expand for full commit details
Update AnchoredDraggable target calculation logic
We were previously relying on currentValue and the next closest anchor in the drag direction, but the simpler and more reliable way is to look at the left and right anchors as the window.
Relnote: Fixed a bug where positional thresholds passed to AnchoredDraggableDefaults.flingBehavior were not considered correctly in some scenarios.
Test: anchoredDraggable_fling_offsetPastHalfwayBetweenAnchors_beforePosThreshold_doesntAdvance
Bug: 367660226
Bug: 366003852
Change-Id: Ifdf0dfcf3d7ff8288affee56e7092bbed473d6ab
Files:
- M
compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/anchoredDraggable/AnchoredDraggableStateTest.kt
- D
compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/anchoredDraggable/AnchoredDraggableTestState.kt
- M
compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/AnchoredDraggable.kt
Hash: eff53304942e9fd4fa5382e0cf487a734c5b8d28
Date: Thu Sep 19 16:24:55 2024
na...@gmail.com <na...@gmail.com> #5
so...@google.com <so...@google.com> #6
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.compose.foundation:foundation:1.8.0-alpha04
androidx.compose.foundation:foundation-android:1.8.0-alpha04
androidx.compose.foundation:foundation-jvmstubs:1.8.0-alpha04
na...@gmail.com <na...@gmail.com> #7
Using the new version 1.8.0-alpha04
does not seem to resolve the issue for me. I tested with the same setting as the reported issue:
// it doesn't matter what you put here a the multiplier, the positionalThreshold is always 50%
positionalThreshold = { d -> d * 0.9f },
velocityThreshold = { Float.POSITIVE_INFINITY },
so...@google.com <so...@google.com>
si...@google.com <si...@google.com> #8
Same. I've run this again on 1.8.0-alpha04. When using
positionalThreshold = { d -> d * 0.1f }
Dragging up to 10% or between 50% and 90% will cause it to snap back to the start anchor. Dragging between 10% and 50% or past 90% will cause it to snap to the end anchor.
I would expect It to only return if dragged less than or equal to 10% and snap to the end if dragged greater than 10%.
When using
positionalThreshold = { d -> d * 0.9f }
It acts as if the threshold has been set to 50%.
From what I can tell, nothing has changed about the behavior.
an...@google.com <an...@google.com> #9
Thanks, we will investigate and update this issue.
si...@google.com <si...@google.com> #10
an...@google.com <an...@google.com> #11
Project: platform/frameworks/support
Branch: androidx-main
Author: Jossi Wolf <
Link:
Update AnchoredDraggable target calculation logic
Expand for full commit details
Update AnchoredDraggable target calculation logic
There was a missed case when the velocity was negative.
Test: New tests with more parameter permutations
Fixes: 367660226
Bug: 376931805
Relnote: "Follow-up fix for an issue in AnchoredDraggable's target calculation where it could settle at the wrong anchor for specific swipes."
Change-Id: I23b8773d3a694aa3c8de6a8f34b9d7fb54cfe560
Files:
- M
compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/anchoredDraggable/AnchoredDraggableStateTest.kt
- M
compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/AnchoredDraggable.kt
Hash: 6a23aa4ee37ba171475e4155db0d24c90b358c7e
Date: Fri Nov 08 14:11:31 2024
si...@google.com <si...@google.com>
si...@google.com <si...@google.com> #12
What is the fix version?
si...@google.com <si...@google.com>
si...@google.com <si...@google.com>
na...@gmail.com <na...@gmail.com> #13
We will comment on the issue when it has been included in a release. Until then, you can try the snapshot versions from androidx.dev.
si...@google.com <si...@google.com>
ji...@gmail.com <ji...@gmail.com> #14
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.compose.foundation:foundation:1.8.0-alpha07
androidx.compose.foundation:foundation-android:1.8.0-alpha07
androidx.compose.foundation:foundation-jvmstubs:1.8.0-alpha07
androidx.compose.foundation:foundation-linuxx64stubs:1.8.0-alpha07
ma...@gmail.com <ma...@gmail.com> #15
ub...@gmail.com <ub...@gmail.com> #16
#15, please report a new issue with a full reproduction case and the versions you are using. Thank you!
ub...@gmail.com <ub...@gmail.com> #17
Running compose foundation 1.8.0-alpha07
I'm using AnchoredDraggable with nested scrolling. When I drag and release the lazy layout sometimes the draggable settles correctly and sometimes it doesn't even when i drag and release past the threshold (positionalThreshold = { distance -> distance / 2f }.
internal fun nestedScrollConnection(
dragState: AnchoredDraggableState<Anchors>,
decayAnimationSpec: DecayAnimationSpec<Float>,
orientation: Orientation = Orientation.Vertical,
): NestedScrollConnection = object : NestedScrollConnection {
override fun onPreScroll(
available: Offset,
source: NestedScrollSource,
): Offset {
val availableDelta = available.toFloat()
return if (
availableDelta < 0f
) dragState.dispatchRawDelta(availableDelta).toOffset()
else Offset.Zero
}
override fun onPostScroll(
consumed: Offset,
available: Offset,
source: NestedScrollSource,
): Offset {
val availableDelta = available.toFloat()
return if (
availableDelta >= 0f
) dragState.dispatchRawDelta(availableDelta).toOffset()
else Offset.Zero
}
override suspend fun onPreFling(
available: Velocity,
): Velocity {
val availableDelta = available.toFloat()
val consumedOffset = if (availableDelta < 0f) dragState.animateToWithDecay(
velocity = availableDelta,
targetValue = Anchors.Collapsed,
decayAnimationSpec = decayAnimationSpec,
) else 0f
return Velocity(
x = 0f,
y = consumedOffset,
)
}
override suspend fun onPostFling(
consumed: Velocity,
available: Velocity,
): Velocity {
val availableDelta = available.toFloat()
if (
availableDelta > 0f
) dragState.animateToWithDecay(
velocity = availableDelta,
targetValue = Anchors.Expanded,
decayAnimationSpec = decayAnimationSpec,
)
dragState.settle(animationSpec = spring())
return Velocity(x = 0f, y = availableDelta)
}
private fun Float.toOffset(): Offset = Offset(
y = if (orientation == Orientation.Vertical) this else 0f,
x = if (orientation == Orientation.Horizontal) this else 0f,
)
@JvmName("offsetToFloat")
private fun Offset.toFloat() = if (orientation == Orientation.Horizontal) x else y
@JvmName("velocityToFloat")
private fun Velocity.toFloat() = if (orientation == Orientation.Horizontal) x else y
}
da...@facile.it <da...@facile.it> #18
Hi, this seems to be a different issue. Please provide a full reproducer in a new issue so we can investigate. Thank you!
si...@google.com <si...@google.com> #19
Or, is there some way to look up which is the first build to contain the change?
si...@google.com <si...@google.com> #20
Looking at the release notes (
ro...@oda.com <ro...@oda.com> #21
Unfortunately, this still does not work. I'm on 1.8.0-alpha07 and when I use 0.9f from the original example it still snaps at 50%.
va...@gmail.com <va...@gmail.com> #22
#21, are you using exactly the same code shared in #1?
ha...@google.com <ha...@google.com> #23
Yes, I'm the OP.
se...@gmail.com <se...@gmail.com> #24
sdkmanager "build-tools;build-tools-version"
da...@decathlon.com <da...@decathlon.com> #25
Apologies #23, but I am not able to reproduce the issue with the sample from #1, running on Compose 1.8.0-alpha08. Can you please provide a full reproducer project as a zip? Thanks!
st...@google.com <st...@google.com> #26
Can confirm that positionalThreshold doesn't work, still snaps at 50%.
Here is composable I'm using to test:
@Composable
fun AnchoredDraggableAnchorsFromCompositionSample() {
val density = LocalDensity.current
val state = rememberSaveable(saver = AnchoredDraggableState.Saver()) {
AnchoredDraggableState(initialValue = DragAnchors.Start)
}
val draggableWidth = 200.dp
val containerWidthPx = with(density) { draggableWidth.toPx() }
// Our anchors depend on the density which is obtained from composition, so we update them using
// updateAnchors whenever they are available
SideEffect {
state.updateAnchors(
DraggableAnchors {
DragAnchors.Start at 0f
DragAnchors.End at containerWidthPx
}
)
}
Box(Modifier.width(draggableWidth).background(Color.Gray)) {
Box(Modifier
.size(50.dp)
.offset { IntOffset(x = state.requireOffset().roundToInt(), y = 0) }
.anchoredDraggable(
state,
Orientation.Horizontal,
flingBehavior =
AnchoredDraggableDefaults.flingBehavior(
state,
positionalThreshold = { distance -> distance * 0.95f }
)
)
.background(Color.Red)
)
}
}
st...@gmail.com <st...@gmail.com> #27
kl...@google.com <kl...@google.com> #29
Closing this since async onValueChange updates are not supported and will continue to not be supported.
ma...@gmail.com <ma...@gmail.com> #30
ap...@google.com <ap...@google.com> #32
Branch: androidx-main
commit 125070eab17fd3d941e8718ec8a5b9b0d88ee3b4
Author: Zach Klippenstein <klippenstein@google.com>
Date: Wed Oct 04 13:14:11 2023
Kdoc polish for BasicTextField.
- Moved all sample links to the bottom. When rendering kdoc, Studio
doesn't render code samples inline, it places them all at the end. Any
text that comes after the first sample link is not rendered at all. So
any important documentation must come before the first sample link or
it will not be shown when users are viewing docs in Studio.
- Cleaned up wording of state management caveats. Our async requirements
weren't obvious, so I stated them explicitly and linked to our more
detailed guide.
Relnote: "Improved documentation on `BasicTextField` regarding
`onValueChange` requirements."
Test: n/a
Bug:
Change-Id: I90fc9dea845dafbf35fd439fe7813b2a752d9189
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/BasicTextField.kt
pr...@google.com <pr...@google.com> #33
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.compose.foundation:foundation:1.6.0-alpha08
androidx.compose.foundation:foundation-android:1.6.0-alpha08
androidx.compose.foundation:foundation-desktop:1.6.0-alpha08
Description
Steps to reproduce:
1. Use OutlinedTextField with the String-based constructor in any composable function
2. Type something long (a sentence or something) into the field
3. Observe the cursor randomly being placed before the letter that was just typed
This is easily worked around by using the constructor that takes a TextFieldValue as value, but should be fixed nonetheless.