-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SelectionContainer not work with any clickable component #1450
SelectionContainer not work with any clickable component #1450
Comments
Reproduced on 1.0.0 |
Any update on this guys? |
I can confirm it does not work still (compose 1.1.1, kotlin 1.6.10) I was trying to wrap the Text with a Box as an InlineTextContent instead of using ClickableText in order to capture clicks - I thought ClickableText was the only one affected. It seems SelectionContainer somehow prevents propagating the click event deeper to the remaining composables |
@akurasov 😂 ? |
Is this problem solved? |
no @ compose 1.4.0, but you might solve your problem by wrapping the part you want to be clickable in DisableSelection. SelectionContainer { Text("selectable text") DisableSelection { } |
Here is another workaround which leaves the whole text selectable: var lastLayoutResult: TextLayoutResult? by remember { mutableStateOf(null) }
BasicText(
text = formattedString,
modifier = modifier
// workaround for https://github.com/JetBrains/compose-multiplatform/issues/1450
// todo: when fixed, change to ClickableText and move logic to onClick parameter
.onPointerEvent(PointerEventType.Release) {
val offset = lastLayoutResult?.getOffsetForPosition(it.changes.first().position) ?: 0
formattedString
.getStringAnnotations(tag = "link", start = offset, end = offset)
.firstOrNull()
?.let { annotation ->
handleLink(annotation.item)
}
},
onTextLayout = { layoutResult ->
lastLayoutResult = layoutResult
}
) |
The workaround using
|
## Proposed Changes - Do not recreate modifier nodes on focus change - Buttons inside `DisableSelection` now clickable. Before it receives only second click - Do not consume UP events if there were no drag before - Buttons inside `SelectionContainer` now clickable, but text inside them is still selectable - `SelectionManager.hasFocus` now `true` if any of it's children is focusable - `onClearSelectionRequested` now triggers on consumed click on focusable, non-selectable child ## Testing Test: `Selection` page in mpp ## Issues Fixed Fixes JetBrains/compose-multiplatform#1450
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks. |
This code works fine on Android but does not respond to desktop clicks
The text was updated successfully, but these errors were encountered: