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

When fr dimensions have a min or max, they should yield their space to flexible units #2378

Closed
davep opened this issue Apr 26, 2023 · 3 comments · Fixed by #2390
Closed

When fr dimensions have a min or max, they should yield their space to flexible units #2378

davep opened this issue Apr 26, 2023 · 3 comments · Fixed by #2390
Labels
bug Something isn't working Task

Comments

@davep
Copy link
Contributor

davep commented Apr 26, 2023

There might be other combinations that result in this, but this is a minimal version of the problem that has been observed in the markdown viewer. Consider this code:

from textual.app        import App, ComposeResult
from textual.containers import Horizontal, Vertical, VerticalScroll
from textual.widgets    import Header, Footer, Static

class ScreenSplitApp( App[ None ] ):

    CSS = """
    Horizontal {
        width: 1fr;
    }

    Vertical {
        width: 1fr;
        background: red;
        min-width: 42;
    }

    VerticalScroll {
        width: 3fr;
        background: $panel;
    }

    Static {
        width: 1fr;
        content-align: center middle;
        border: double red;
    }

    Static.stripe-0 {
        background: green;
    }

    Static.stripe-1 {
        background: blue;
    }
    """

    def compose( self ) -> ComposeResult:
        yield Header()
        with Horizontal():
            yield Vertical()
            with VerticalScroll():
                for n in range( 500 ):
                    yield Static( f"This is content number {n}", classes=f"stripe-{n % 2}" )
        yield Footer()

if __name__ == "__main__":
    ScreenSplitApp().run()

When the terminal is wide enough that the min-width on the Vertical isn't activated, the VerticalScroll has its scrollbar and works as would be expected:

Screenshot 2023-04-26 at 10 36 15

However, if the terminal is narrowed enough that the min-width kicks in on the Vertical on the left, the VerticalScroll on the right drops its scrollbar (or perhaps retains it but it's off the screen) and the content starts to get cropped.

Screenshot 2023-04-26 at 10 37 53

@davep davep added bug Something isn't working Task labels Apr 26, 2023
@willmcgugan
Copy link
Collaborator

from textual.app import App, ComposeResult
from textual.containers import Horizontal, Vertical, VerticalScroll
from textual.widgets import Header, Footer, Static


class ScreenSplitApp(App[None]):
    CSS = """
    Horizontal {
        width: 1fr;        
    }

    Vertical {
        width: 1fr;
        background: blue;
        min-width: 20;
    }

    VerticalScroll {
        width: 3fr;
        background: $panel;
    }

    Static {
        width: 1fr;
        content-align: center middle;
    }

    """

    def compose(self) -> ComposeResult:
        yield Header()
        with Horizontal():
            yield Vertical()
            with VerticalScroll():
                for n in range(500):
                    yield Static(f"This is content number {n}")
        yield Footer()


if __name__ == "__main__":
    ScreenSplitApp().run()

@willmcgugan
Copy link
Collaborator

What appears to be happening is that when a fr unit reaches its minimum, it is still treated as a fraction - so the remaining fr units won't shrink.

@davep In the meantime, I think you should dock the sidebar to a fixed width.

@willmcgugan willmcgugan changed the title Unexpected VerticalScroll scrollbar loss when adjacent to a min-width container When fr dimensions have a min or max, they should yield their space to flexible units Apr 26, 2023
davep added a commit to davep/textual-sandbox that referenced this issue Apr 26, 2023
davep added a commit to Textualize/frogmouth that referenced this issue Apr 26, 2023
@github-actions
Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

talblubClouby96 added a commit to talblubClouby96/frogmouth that referenced this issue Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Task
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants