Wrong size when text is long on macOS
BeBeBerr opened this issue · comments
Describe the bug
When text is long, the window is expanded with extra space and cannot be resized. However, if the text is short, everything is fine.
Checklist
- I can reproduce this issue with a vanilla SwiftUI project.
- I can reproduce this issue using the
main
branch of this package. - This bug hasn't been addressed in an existing GitHub issue.
Steps to reproduce
When text is very long:
import SwiftUI
import MarkdownUI
struct ContentView: View {
var body: some View {
Markdown("1232313123123123131312323131231231231313123231312312312313131232313123123123131312323131231231").border(Color.pink)
}
}
The layout becomes weird. The window is actually way longer than my screen and I couldn't capture the whole window.
However, if I delete some text, everything is fine and I can resize the window with no issue.
![Screenshot 2023-12-20 at 2 45 00 PM](https://private-user-images.githubusercontent.com/22321356/291804912-e70210c7-b783-4b4c-9048-a8ca092505fd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg3Mjc3MzIsIm5iZiI6MTcxODcyNzQzMiwicGF0aCI6Ii8yMjMyMTM1Ni8yOTE4MDQ5MTItZTcwMjEwYzctYjc4My00YjRjLTkwNDgtYThjYTA5MjUwNWZkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjE4VDE2MTcxMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM1OTUwMDA2ZDM4OWE5MzEyMzc5Y2U1MGNlZjA2OWJkNzllYWJlYjhhNjk1ZTIxMWE5YTg5MTVhMGE3NTcyM2EmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.FFi0v5-kQ_zYL0S1J9f-Qw1WpGeeN44yocsgpq4Wj4w)
Version information
- MarkdownUI: main
- OS: macOS 14
- Xcode: 15
This issue is introduced in version 2.0.0. Version 1.1.1 has no such issue.
Any help will be appreciated!
Hi @BeBeBerr,
What is happening is that the current theme is applying the fixedSize(horizontal: false, vertical: true)
on the paragraph contents.
You can workaround this issue by overriding the current paragraph style. For instance:
struct ContentView: View {
var body: some View {
Markdown("1232313123123123131312323131231231231313123231312312312313131232313123123123131312323131231231")
.markdownBlockStyle(\.paragraph) { configuration in
configuration.label
.relativeLineSpacing(.em(0.15))
.markdownMargin(top: .zero, bottom: .em(1))
}
.border(Color.pink)
.padding()
}
}
Thanks for replying! Is this considered as a bug and is there any plans to fix it? @gonzalezreal