Skip to content

Custom spans not following the scroll offset of the TextField itself #601

@pChochura

Description

@pChochura

I've stumbled upon an issue while creating a similar library on my own and was wondering how you solved it.
It turned out, you didn't 😄

In the examples and frequent use cases the RichTextEditor composable has its height wrapping the content and in that scenario the custom spans are rendered correctly. But whenever you set the max size on the RichTextEditor (without a line limit), you can scroll the content of the TextField itself but the custom spans are still rendered as if they weren't offsetted.

Example (straight up from the sample project in the repo with the additional height Modifier):

OutlinedRichTextEditor(
    modifier = Modifier.fillMaxWidth().height(200.dp),
    state = outlinedRichTextState,
    textStyle = LocalTextStyle.current.copy(fontFamily = FontFamily.Monospace),
)
Screen_recording_20250611_171104.mp4

FYI, the only implementation of the BasicTextField that allows you to manipulate the scroll offset, does not use the AnnotatedText 🙃

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions