-
-
Notifications
You must be signed in to change notification settings - Fork 993
Description
I have been struggling with not being able to properly displaying TextArea
s inside Collapsible
widgets. After many hours of testing I concluded that indeed this is probably not how it's supposed to work. Couldn't replicate with ListView
s instead of Collapsible
s and neither with other widgets inside Collapsible
.
from textual.app import App, ComposeResult
from textual.highlight import highlight
from textual.widgets import Collapsible, Static, TextArea
class MyApp(App):
CSS = """
Screen {
align: center middle;
}
"""
def compose(self) -> ComposeResult:
# fmt: off
yield from compose_glitch("A) text area cut ~ Where is the bottom of TextArea?")
yield from compose_glitch("A) text area stretched ~ Why is TextArea stretched here like so?")
yield from compose_glitch("B) static cut ~ Where is key '48'?", reverse=True)
yield from compose_glitch("B) static cut, text area stretched ~ Where is key 'last'?", reverse=True)
# fmt: on
def compose_glitch(glitch, reverse: bool = False):
widgets = [
Static(highlight(gen_text(glitch), language="yaml")),
TextArea(gen_text(glitch), language="yaml", read_only=True, show_line_numbers=True),
]
yield Collapsible(*(reversed(widgets) if reverse else widgets), title=glitch)
def gen_text(glitch):
if "text area stretched" in glitch:
return "\n".join(["first: null", "last: null"])
return "\n".join(["first: null", *(f"{n}: {hex(n)}" for n in range(1, 48)), "last: null"])
if __name__ == "__main__":
MyApp().run()
Issue can be mitigated with setting a concrete height
for either TextArea
or Collapsible
's Contents
. But analysing Collapsible
's and its components' CSS configs did not point me to any direction, it all seems to be "auto". But it doesn't do that right as these examples show.
It's tempting to think it's just one or two lines of error with the cuts but there can be more than that, I could replicate that reliable as of yet. Also, I have encountered where as if the virtual size of TextArea influenced a parent container's virtual size but I will attempt to post example of that maybe later.