Skip to content
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

Clickable links in SelectionContainer are no longer clickable #103

Open
sebkur opened this issue Dec 6, 2022 · 2 comments
Open

Clickable links in SelectionContainer are no longer clickable #103

sebkur opened this issue Dec 6, 2022 · 2 comments

Comments

@sebkur
Copy link

sebkur commented Dec 6, 2022

Here's an example. With the SelectionContainer selecting the text is possible, but clicking the link does nothing. Without it, clicking the link works, but selecting text doesn't work of course:

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material.Text
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.singleWindowApplication
import com.halilibo.richtext.markdown.Markdown
import com.halilibo.richtext.ui.RichText

fun main() {
    singleWindowApplication {
        LazyColumn {
            item {
                Text("Foo")
            }
            item {
                SelectionContainer {
                    RichText(modifier = Modifier.padding(vertical = 8.dp).fillMaxWidth()) {
                        Markdown("[Google](https://www.google.com)", onLinkClicked = { link ->
                            println(link)
                        })
                    }
                }
            }
        }
    }
}

Is there some other way to make text selectable or is this is a bug?

@morrisseyai
Copy link
Contributor

Hi @sebkur, I saw your post on Slack but figured I would answer in both places, to help anyone else who also searches for this issue.

I believe the problem is actually related to this open issue on Compose for Desktop: JetBrains/compose-multiplatform#1450

As a side note: Earlier this year I made some improvements to how we handle clickable text in compose-richtext which solved a common problem developers have with the standard ClickableText component - that is, ClickableText consumes all tap interactions rather than the ones it should be responsible for, which causes a follow-on effect where you lose interaction effects like the ripple on Android, and you lose the ability to allow parent Composables to handle tap events.

☝️ what all this means is that if JetBrains are able to resolve the SelectionContainer issue then having clickable and selectable text in compose-richtext should just work with no changes required by us.

Hope that helps, reach out if you need more info.

@sebkur
Copy link
Author

sebkur commented Dec 7, 2022

Thanks @morrisseyai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants