Skip to content

Problem with scrollable containers #4187

@jakubziebin

Description

@jakubziebin

There seems to be a problem with scrollable containers. Consider an example:

from __future__ import annotations

from textual.app import App, ComposeResult
from textual.widgets import Label
from textual.containers import ScrollableContainer, Grid


class MyApp(App):
    DEFAULT_CSS = """
    Grid {
        grid-size: 2;
        grid-rows: auto;
        height: auto;
    }
    
    Label {
        height: 1;
        background: red;
    }
    """

    def compose(self) -> ComposeResult:
        with ScrollableContainer(), Grid():
            yield Label("First")
            yield Label("Second")
            yield Label("Third")
            yield Label("Fourth")
            yield Label("Fifth")
            yield Label("Sixth")


MyApp().run()

In this case I would expect the scroll to appear when the Fifth and Sixth labels are hidden, but:
image
There is no reaction.
After adding some padding, scroll appears when all the labels are hidden, and when I scroll down I don't see any of them.

I have noticed a similar problem with TabbedContent:

from __future__ import annotations

from textual.app import App, ComposeResult
from textual.widgets import Label, TabPane, TabbedContent
from textual.containers import ScrollableContainer, Grid


class MyTabPane(TabPane):
    DEFAULT_CSS = """
    Grid {
        grid-size: 2;
        grid-rows: auto;
        padding: 2 4;
        height: auto;
    }

    Label {
        height: 1;
        background: red;
    }
    """

    def compose(self) -> ComposeResult:
        with ScrollableContainer(), Grid():
            yield Label("First")
            yield Label("Second")
            yield Label("Third")
            yield Label("Fourth")
            yield Label("Fifth")
            yield Label("Sixth")


class MyApp(App):
    def compose(self) -> ComposeResult:
        with TabbedContent():
            yield MyTabPane("example")


MyApp().run()

This is when the scroll appears and again I can't see any element that is under the ScrollableContainer.
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions