Skip to content

Commit

Permalink
Fix content rect calculation in SelectionManager (#1270)
Browse files Browse the repository at this point in the history
## Proposed Changes

**Cherry-picked from androidx**

Fix a typo in `SelectionManager.getContentRect()` that results in an
invalid rect being calculated, causing text toolbar to not show under
certain conditions.

Fixes: b/332782845
Test: manual
Change-Id: I153b99f4146d870182af2898d9a675ed6ffa15e4

## Testing

Test: Open test app, go Components -> Selection, try to select text in
selection container

## Issues Fixed

Fixes: appearing of editing menu in selection container in wrong
position

https://youtrack.jetbrains.com/issue/COMPOSE-1190/iOS-Selection-Container-cant-show-options-menu
JetBrains/compose-multiplatform#4322
b/332782845 in Google

## Google CLA
You need to sign the Google Contributor’s License Agreement at
https://cla.developers.google.com/.
This is needed since we synchronise most of the code with Google’s AOSP
repository. Signing this agreement allows us to synchronise code from
your Pull Requests as well.

Co-authored-by: Albert Chang <mxalbert1996@gmail.com>
  • Loading branch information
mazunin-v-jb and mxalbert1996 committed Apr 19, 2024
1 parent 29ee4d3 commit cd47b70
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ internal class SelectionManager(private val selectionRegistrar: SelectionRegistr
if (visibleRect.width < 0 || visibleRect.height < 0) return null

val rootRect = visibleRect.translate(containerCoordinates.positionInRoot())
return rootRect.copy(bottom = visibleRect.bottom + HandleHeight.value * 4)
return rootRect.copy(bottom = rootRect.bottom + HandleHeight.value * 4)
}

// This is for PressGestureDetector to cancel the selection.
Expand Down

0 comments on commit cd47b70

Please sign in to comment.