Skip to content

Commit 6cfa741

Browse files
authored
Copy Jetpack Compose 1.10.2 (#2730)
[CMP-9679](https://youtrack.jetbrains.com/issue/CMP-9679) Merge Jetpack Compose 1.10.2 | GroupId | ReleaseVersion | ReleaseSHA | ReleaseBuildId | ReleaseDate | | --- | --- | --- | --- | --- | | androidx.compose.animation | 1.10.2 | fc5dfcf | 14756242 | 1/28/2026 | | androidx.compose.foundation | 1.10.2 | fc5dfcf | 14756242 | 1/28/2026 | | androidx.compose.material | 1.10.2 | fc5dfcf | 14756242 | 1/28/2026 | | androidx.compose.runtime | 1.10.2 | fc5dfcf | 14756242 | 1/28/2026 | | androidx.compose.ui | 1.10.2 | fc5dfcf | 14756242 | 1/28/2026 | ## Release Notes N/A
2 parents 29a81c3 + 0c43fde commit 6cfa741

File tree

5 files changed

+62
-13
lines changed

5 files changed

+62
-13
lines changed

compose/foundation/foundation/src/androidDeviceTest/kotlin/androidx/compose/foundation/text/selection/SelectionContainerTest.kt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ import androidx.compose.foundation.text.Handle
3333
import androidx.compose.foundation.text.test.assertThatIntRect
3434
import androidx.compose.runtime.CompositionLocalProvider
3535
import androidx.compose.runtime.LaunchedEffect
36+
import androidx.compose.runtime.getValue
37+
import androidx.compose.runtime.movableContentOf
38+
import androidx.compose.runtime.mutableStateOf
39+
import androidx.compose.runtime.remember
40+
import androidx.compose.runtime.setValue
3641
import androidx.compose.ui.Alignment
3742
import androidx.compose.ui.Modifier
3843
import androidx.compose.ui.geometry.Offset
@@ -573,6 +578,47 @@ internal class SelectionContainerTest : AbstractSelectionContainerTest() {
573578
rule.runOnIdle { assertThat(clickCounter).isEqualTo(1) }
574579
}
575580

581+
@Test
582+
fun selectionContainer_insideDisappearingMovableContent_withActiveSelection() =
583+
with(rule.density) {
584+
var toggle by mutableStateOf(true)
585+
rule.setContent {
586+
val content = remember {
587+
movableContentOf {
588+
SelectionContainer(
589+
modifier = Modifier.testTag("selectionContainer"),
590+
selection = selection.value,
591+
onSelectionChange = { selection.value = it },
592+
) {
593+
TestText(textContent)
594+
}
595+
}
596+
}
597+
if (toggle) {
598+
content()
599+
} else {
600+
TestText("Hello")
601+
}
602+
}
603+
val characterSize = fontSize.toPx()
604+
// Act. Long Press "m" in "Demo", and "Demo" should be selected.
605+
rule.onSelectionContainer().performTouchInput {
606+
longClick(Offset(textContent.indexOf('m') * characterSize, 0.5f * characterSize))
607+
}
608+
609+
// Assert.
610+
rule.mainClock.advanceTimeByFrame()
611+
assertAnchorInfo(selection.value?.start, offset = 5, selectableId = 1)
612+
assertAnchorInfo(selection.value?.end, offset = 9, selectableId = 1)
613+
614+
// Act 2. Remove movableContentOf from composition
615+
toggle = false
616+
rule.mainClock.advanceTimeByFrame()
617+
618+
// Assert. No crash is enough
619+
assertThat(selection.value).isNull()
620+
}
621+
576622
private fun startSelection(tag: String, offset: Int = 0) {
577623
val textLayoutResult = rule.onNodeWithTag(tag).fetchTextLayoutResult()
578624
val boundingBox = textLayoutResult.getBoundingBox(offset)

compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/text/contextmenu/internal/AndroidTextContextMenuToolbarProvider.android.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,13 @@ internal class AndroidTextContextMenuToolbarProvider(
225225
observeReadsAndGet("dataBuilder", onDataChange) { dataProvider.data() }
226226

227227
private fun observeAndGetBounds(dataProvider: TextContextMenuDataProvider): Rect =
228-
observeReadsAndGet("positioner", onPositionChange) { calculateBoundsInRoot(dataProvider) }
229-
230-
private fun calculateBoundsInRoot(dataProvider: TextContextMenuDataProvider): Rect {
231-
val destinationCoordinates = coordinatesProvider()
232-
val localBoundingBox = dataProvider.contentBounds(destinationCoordinates)
233-
return localBoundingBox.translate(destinationCoordinates.positionInRoot())
234-
}
228+
observeReadsAndGet("positioner", onPositionChange) {
229+
val destinationCoordinates =
230+
coordinatesProvider().takeIf { it.isAttached }
231+
?: return@observeReadsAndGet Rect.Zero
232+
val localBoundingBox = dataProvider.contentBounds(destinationCoordinates)
233+
localBoundingBox.translate(destinationCoordinates.positionInRoot())
234+
}
235235

236236
/**
237237
* Same functionality as [SnapshotStateObserver.observeReads] except this function returns the

compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/contextmenu/modifier/TextContextMenuToolbarHandlerModifier.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,16 @@ internal class TextContextMenuToolbarHandlerNode(
219219
override fun position(destinationCoordinates: LayoutCoordinates): Offset =
220220
contentBounds(destinationCoordinates).topLeft
221221

222-
// This can update as the modifier is getting disposed,
223-
// so return zero if we aren't attached to avoid crashing.
222+
/**
223+
* This can update as the modifier is getting disposed, so return zero if we aren't attached to
224+
* avoid crashing. However the caller is responsible for providing a valid and attached
225+
* [destinationCoordinates].
226+
*/
224227
override fun contentBounds(destinationCoordinates: LayoutCoordinates): Rect {
225228
if (!isAttached) return previousContentBounds
226229

227-
val computedContentBounds = computeContentBounds(destinationCoordinates)
228-
if (computedContentBounds == null) return previousContentBounds
230+
val computedContentBounds =
231+
computeContentBounds(destinationCoordinates) ?: return previousContentBounds
229232

230233
previousContentBounds = computedContentBounds
231234
return computedContentBounds

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ jetbrains.compose.compiler.version=1.5.14.1
106106
# artifactRedirection.version.<redirectionGroup>.<redirectionModule>
107107
# covers all sub-module projects
108108
# (artifactRedirection.version.androidx.compose covers androidx.compose.*:*)
109-
artifactRedirection.version.androidx.compose=1.10.1
109+
artifactRedirection.version.androidx.compose=1.10.2
110110
artifactRedirection.version.androidx.compose.material3=1.5.0-alpha08
111111
artifactRedirection.version.androidx.compose.material3.adaptive=1.3.0-alpha03
112112
artifactRedirection.version.androidx.compose.material3.common=1.0.0-alpha01

libraryversions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ CAMERA_VIEWFINDER = "1.4.0-alpha08"
1919
CARDVIEW = "1.1.0-alpha01"
2020
CAR_APP = "1.7.0-beta02"
2121
COLLECTION = "1.5.0-alpha03"
22-
COMPOSE = "1.10.1"
22+
COMPOSE = "1.10.2"
2323
COMPOSE_MATERIAL3 = "1.5.0-alpha08"
2424
COMPOSE_MATERIAL3_ADAPTIVE = "1.3.0-alpha03"
2525
COMPOSE_RUNTIME_TRACING = "1.0.0-beta01"

0 commit comments

Comments
 (0)