[go: nahoru, domu]

Clear selection on selectable change

When the underlying text of a selection changed, the selection was not updated causing the content and selection to be out of sync. Instead, we will now simply clear the selection when the underlying text changes.

Test: SelectionCopyTest
Fixes: b/322066508
Change-Id: Iee0bdd28b78967290696440e747427f4e182bf8c
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionManager.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionManager.kt
index 87a3f18..5808ef2 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionManager.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionManager.kt
@@ -304,6 +304,8 @@
             currentDragPosition = null
         }
 
+        // This function is meant to handle changes in the selectable content,
+        // such as the text changing.
         selectionRegistrar. selectableKey ->
             if (selectableKey in selectionRegistrar.subselections) {
                 // Clear the selection range of each Selectable.