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

Slashes with text ellipsis overflow behaves differently than Android (Desktop) #1888

Closed
JetpackDuba opened this issue Feb 23, 2022 · 11 comments · Fixed by JetBrains/compose-multiplatform-core#899
Assignees
Labels
bug Something isn't working skia text

Comments

@JetpackDuba
Copy link
Contributor

When I have got a Text with slashes (like a file path) as text that doesn't fit the current screen, in the Android version of compose the string gets cut partially and not the whole word. The Desktop version cuts the whole word instead until the slash.

Desktop: "FooBar" is not shown, just the ellipsis.

Desktop
ellipsis

Android: "Foo" is shown + Ellipsis

Android

Code sample:

MaterialTheme {
    Text(
        text = "/Path/To/A/Fantastic/Path/Named/FooBar",
        overflow = TextOverflow.Ellipsis,
        fontSize = 23.sp,
        maxLines = 1,
    )
}

TextOverflow.Clip behaves in equally in both platform by cutting the whole word.

@JetpackDuba
Copy link
Contributor Author

JetpackDuba commented Mar 4, 2022

I'm testing on windows now and surprisingly it works properly there, so seems something related to the linux implementation (no idea about macOS).

Edit: Nevermind, the issue reproduces also on Windows, I did a small mistake when testing it, my apologies.

@akurasov
Copy link
Contributor

akurasov commented Mar 4, 2022

Tried on MacOS. It works same way as your desktop example

@akurasov akurasov added question Not a bug, but question or comment desktop labels Mar 4, 2022
@SerVB
Copy link
Member

SerVB commented Dec 1, 2022

Also bumped to this. An example from Android: https://developer.android.com/jetpack/compose/text#text-overflow

@Composable
fun OverflowedText() {
    Text("Hello Compose ".repeat(50), maxLines = 2, overflow = TextOverflow.Ellipsis)
}

grafik

But on desktop, it seems it tends to replace the whole word by ellipsis often. I can have Compo... but after I reduce the size of the window a little, it becomes not Comp... but just .... Increasing the size makes it Compos... and Compose..., so it's not always reproduced.

@mazunin-v-jb mazunin-v-jb added bug Something isn't working and removed question Not a bug, but question or comment labels Aug 16, 2023
@Sage-Kreiter
Copy link

Sage-Kreiter commented Sep 19, 2023

Any updates on this? Seems like very strange behavior to cut off the text at a "/" or "-" on desktop.

Without overflow = TextOverflow.Ellipsis:

image

With overflow = TextOverflow.Ellipsis and maxLines = 1:

image

@dima-avdeev-jb
Copy link
Contributor

@Sage-Kreiter Can you please provide code snippet to reproduce this problem?

@Sage-Kreiter
Copy link

Sage-Kreiter commented Sep 20, 2023

Here is a Box with Text that overflows

    Box(
        modifier = Modifier
            .size(300.dp)
            .border(width = 1.dp, color = MaterialTheme.colors.secondaryVariant)
    ) {
        Text(
            text = "Baconipsumdolorametjowlfatbackribeyestripsteak,sirloinbiltonghamhock",
            maxLines = 1,
            overflow = TextOverflow.Ellipsis
        )
    }

image

Here is a Box with text that overflows but contains a space as the 3rd character (same happens with "/" and "-")

    Box(
        modifier = Modifier
            .size(300.dp)
            .border(width = 1.dp, color = MaterialTheme.colors.secondaryVariant)
    ) {
        Text(
            text = "Ba onipsumdolorametjowlfatbackribeyestripsteak,sirloinbiltonghamhock",
            maxLines = 1,
            overflow = TextOverflow.Ellipsis
        )
    }

image

Could just be that I'm missing a setting to not end on a delimeter

@MatkovIvan
Copy link
Member

This behaviour is defined in skia, Compose itself doesn't control it. It has been already fixed in this commit - https://skia.googlesource.com/skia.git/+/0d31aa1f49cb8cfd790c44d92a9a023839524865
So, it should be fixed once we migrate to new skia version

@Sage-Kreiter
Copy link

Great. Thanks for looking into this

Ikutsu added a commit to kotpot/cosmos-client that referenced this issue Oct 12, 2023
MatkovIvan added a commit to JetBrains/compose-multiplatform-core that referenced this issue Nov 10, 2023
## Proposed Changes

- Update skiko to `0.7.87`

## Issues Fixed

Fixes JetBrains/compose-multiplatform#1888
<img width="310" alt="image"
src="https://github.com/JetBrains/compose-multiplatform-core/assets/1836384/dd28cc81-1d5d-4119-b9fa-0e1e4e28f794">

---------

Co-authored-by: Igor Demin <igor.demin@jetbrains.com>
eymar pushed a commit to JetBrains/compose-multiplatform-core that referenced this issue Dec 5, 2023
## Proposed Changes

- Update skiko to `0.7.87`

## Issues Fixed

Fixes JetBrains/compose-multiplatform#1888
<img width="310" alt="image"
src="https://github.com/JetBrains/compose-multiplatform-core/assets/1836384/dd28cc81-1d5d-4119-b9fa-0e1e4e28f794">

---------

Co-authored-by: Igor Demin <igor.demin@jetbrains.com>

(cherry picked from commit 3d00945)
@sunny-chung
Copy link

Which release can I find the fix? I tried 1.5.11 but it does not contain this fix.

@MatkovIvan
Copy link
Member

Which release can I find the fix?

It will be available in 1.6.0

mazunin-v-jb pushed a commit to JetBrains/compose-multiplatform-core that referenced this issue Dec 7, 2023
## Proposed Changes

- Update skiko to `0.7.87`

## Issues Fixed

Fixes JetBrains/compose-multiplatform#1888
<img width="310" alt="image"
src="https://github.com/JetBrains/compose-multiplatform-core/assets/1836384/dd28cc81-1d5d-4119-b9fa-0e1e4e28f794">

---------

Co-authored-by: Igor Demin <igor.demin@jetbrains.com>
@okushnikov
Copy link
Collaborator

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working skia text
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants