Skip to content

Hint ScrollContainers properly in non-scrolling directions #4503

Description

@johnzhou721

Describe the bug

On all platforms, when the content of a ScrollContainer has a minimum size in a non-scrollable direction (e.g. a widget with minimum width as the content of a horizontally non-scrollable ScrollContainer), the ScrollContainer is still allowed to shrink in the nonscrollable axis beyond a size necessary to present the content.

How to reproduce the bug

  1. Run the example code
  2. See how you can shrink the window beyond 500px which is the minimum size of the content.

Minimum example code

import toga
from toga.style import Pack
from toga.style.pack import COLUMN


class ScrollTest(toga.App):
    def startup(self):
        content = toga.Box()
        content.width = 500
        content.background_color = "magenta"

        scroll = toga.ScrollContainer(
            horizontal=False,  # disable horizontal scrolling
            vertical=True,
            content=content,
            style=Pack(flex=1),
        )

        self.main_window = toga.MainWindow(title=self.formal_name)
        self.main_window.content = scroll
        self.main_window.show()
ScrollTest('1', '2.3').main_loop()

Screenshots

Shrinked window:

Image

Actual minimum size of content:

Image

Environment details

  • Operating system and version: macOS 26.3.1
  • Python version: Python 3.13.0
  • Software versions:

Logs

No response

Additional context

I believe that the fix will be in the rehint() of each backend.

The two different scrollbars will interact with the minimum sizing, so that must be handled properly.

On macOS, opaque scrollbars may be shown at all times through a setting, which can be changed at runtime; that must be handled appropriately, even though macOS usually uses a translucent scrollbar.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA crash or error in behavior.

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Ready

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions