rio
rio copied to clipboard
Weird interaction between Switcher and Grid
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
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,
),
)
I have a similar problem