rio icon indicating copy to clipboard operation
rio copied to clipboard

Weird interaction between Switcher and Grid

Open Aran-Fey opened this issue 10 months ago • 2 comments

Describe the bug

The animation of a Switcher somehow affects the layout of its parent Grid.

Steps to Reproduce

class Demo(rio.Component):
    is_on: bool = False
    
    def build(self) -> rio.Component:
        return rio.Grid(
            [
                rio.Switch(is_on=self.bind().is_on),
                rio.Text('foo', align_x=0, grow_x=True),
            ],
            [rio.Switcher(rio.Text('Hello') if self.is_on else None)],
            min_width=10,
        )

Screenshots/Videos

No response

Operating System

No response

What browsers are you seeing the problem on?

No response

Browser version

No response

What device are you using?

No response

Additional context

No response

Aran-Fey avatar Feb 22 '25 15:02 Aran-Fey

It seems that components that span multiple columns somehow affect the widths and/or grows of the columns. Observe how the length of the text affects the width of the first column here:

class SampleComponent(rio.Component):
    def build(self):
        return rio.Column(
            rio.Grid(
                [rio.Text('foo'), rio.Text('bar', grow_x=True)],
                [rio.Text('a pretty long text here')],
                align_x=0,
                min_width=20,
            ),
            rio.Grid(
                [rio.Text('foo'), rio.Text('bar', grow_x=True)],
                [rio.Text('tiny text')],
                align_x=0,
                min_width=20,
            ),
        )

Aran-Fey avatar Feb 28 '25 18:02 Aran-Fey

I have a similar problem

Dumbliidore avatar May 14 '25 06:05 Dumbliidore