-
Notifications
You must be signed in to change notification settings - Fork 788
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
Content height of markdown does not take border/padding into account #4522
Comments
From what I can see with your example, the same effect happens without wrapping the
A I've not really dived into this, but the minimal version of what you're seeing seems to be this: from textual.app import App, ComposeResult
from textual.containers import Grid
from textual.widgets import Label
def long_text() -> str:
return "aaa naa aaaaa aaa aaaan, aaa\naaa, aaaa?\", aa aaa aaaaanaaa *anaaaaaaana* aaaaaaaa aaaaaana aaa aaaaa aa\naaa, aa *aaaaaaaaa* aaa aaaa, \"aaaa, an *aaaa* aaa aaaa, a aa\". \"aaaa, naa\naaaaaaaaaaa, aaa a aaaa aaaaaanaa aaaa aa a aaa!\", aaa anaaaa, aaaaa\naaaaaaaa aanaaaaa. \"Na! aaa naa. aaaaa. aa aaaaa naa. aaaaa aa na aaa.\",\naaa aaaaaaaa aaaanaaaaa DONE.\n"
class LongLabelApp(App[None]):
CSS = """
Grid {
width: 60;
border: solid red;
}
"""
def compose(self) -> ComposeResult:
with Grid():
yield Label(long_text())
if __name__ == "__main__":
LongLabelApp().run() and it seems to be fixed with: --- long_label.py-orig 2024-05-19 12:29:34
+++ long_label.py 2024-05-19 12:29:47
@@ -16,7 +16,7 @@
"""
def compose(self) -> ComposeResult:
with Grid():
- yield Label(long_text())
+ yield Label(long_text(), shrink=True)
if __name__ == "__main__":
LongLabelApp().run() Footnotes
|
It very much seems to be the same symptom, with "I couldn't reproduce it without wrapping it in a Tab, but that might be lack of imagination on my part in mind I was hoping it would be possible to narrow the problem you're seeing down to the bare minimum code. From what I can see that's much of the DOM stripped, and some of the styling stripped, while still retaining the same symptom you're seeing. While toggling the value of Aside: if you've run into styling issue with Textual's |
This looks like an issue with grid. Fix incoming. |
Fixed in 0.61.1 |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
And you seem to have been correct with that assessment :P I wasn't sure if that was the same problem or not and wanted to at least mention that. My example was already reduced a lot from my original code, but I didn't find any straightforward further reduction with the same symptoms (contrary to you) :)
The Label(Markdown) is totally adequate for my usecase right now, but I will keep that in mind. Thanks :)
That also works on my real code! Thank you so much :) |
Description
The auto height of a Label with a markdown element in it is wrong if the label is subject to padding (and sometimes a border is enough too). I couldn't reproduce it without wrapping it in a Tab, but that might be lack of imagination on my part.
As the content height is wrong, no scrollbar appears either and I could not not coax it into displaying any. The content is just silently truncated and lost to the aether.
Diagnose
Expand for diagnosis
Versions
Python
Operating System
Terminal
Rich Console options
Screenshots
Without padding
With padding
Code
The text was updated successfully, but these errors were encountered: