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

ASTextNode text is overflowed whereas left padding is given #2087

Open
abbasnaqvi200 opened this issue Aug 25, 2023 · 1 comment
Open

ASTextNode text is overflowed whereas left padding is given #2087

abbasnaqvi200 opened this issue Aug 25, 2023 · 1 comment

Comments

@abbasnaqvi200
Copy link

Why ASTextNode is overflowing instead of truncating…

HStackLayout(alignItems: .center) {
img1.preferredSize(.init(width: 20, height: 20)).padding(.left, 9)
img2.preferredSize(.init(width: 20, height: 20))
textNode.padding(.left, 6)
}
IMG_275CCDD3349C-1

@VAndrJ
Copy link

VAndrJ commented Aug 28, 2023

You need to set style.flexShrink not equal to 0 for your padding.

Example without style.flexShrink:

Row {
    imageNode1
        .sized(CGSize(same: 20))
        .padding(.left(9))
    imageNode2
        .sized(CGSize(same: 20))
    textNode
        .padding(.horizontal(6))
}
Screenshot 2023-08-28 at 09 43 11

Example with style.flexShrink:

Row {
    imageNode1
        .sized(CGSize(same: 20))
        .padding(.left(9))
    imageNode2
        .sized(CGSize(same: 20))
    textNode
        .padding(.horizontal(6))
        .flex(shrink: 0.1)
}
Screenshot 2023-08-28 at 09 47 57

And with textNode.maximumNumberOfLines = 1:
Screenshot 2023-08-28 at 09 46 47

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