-
Notifications
You must be signed in to change notification settings - Fork 8
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
MarkdownText
conflicts with `Modifier.clickable
#7
Comments
I deliberately didn't want clicks to get intercepted at the top-level, so URLs would be clickable with their own handlers. One usually wants clicks to be handled at the lowest-level. What level are you expecting to be clickable? The TextView? I assume you wouldn't want to also handle clicks on URLs or anything linkified in the same click handler? |
I'd like to add an |
@lneugebauer |
@miloszelko how do you resolve |
LocalContext.current keeps the local context inside of Compose and you can pass it in. Just be careful about passing context to long running jobs as you may not want memory leaks after the view should go away. |
Description:
When using the
MarkdownText
composable from the library, it renders the markdown content using anAndroidView
. However, I encountered an issue where adding aModifier.clickable
to theMarkdownText
or any of its parent containers does not register click events properly. This behavior creates conflicts when I try to wrap theMarkdownText
with clickable elements for interaction.Steps to Reproduce:
MarkdownText
in a Jetpack Compose component.Box
orRow
with aModifier.clickable
to detect taps.onClick
callback is never triggered.Expected Behavior:
Modifier.clickable
should register the click event when the markdown text is tapped.onClick
callback provided to theModifier.clickable
should be triggered.Actual Behavior:
clickable
modifier does not work when applied toMarkdownText
or its parent containers.AndroidView
used internally byMarkdownText
is blocking gesture events from reaching the Jetpack Compose layout.Possible Cause:
The
MarkdownText
composable usesAndroidView
under the hood to render markdown content via theMarkwon
library. SinceAndroidView
bridges the Android View system with Jetpack Compose, it consumes touch events internally, preventing them from propagating properly to the outer composables.This is a known issue when mixing
AndroidView
with Compose gesture handlers, as the Android view hierarchy does not seamlessly cooperate with the Compose UI system.Workaround Attempts:
I tried a few potential solutions, but none resolved the issue:
Suggested Solutions:
Expose a
onClick
callback directly in theMarkdownText
composable. This way, the click events can be handled internally within theAndroidView
.Example API:
Alternatively, provide guidance on how to integrate
MarkdownText
with Compose'sclickable
modifier or gesture detection.Environment:
latest
latest
latest
The text was updated successfully, but these errors were encountered: