rio-labs / rio

WebApps in pure Python. No JavaScript, HTML and CSS needed
https://rio.dev
Apache License 2.0
1.32k stars 38 forks source link

[BUG]: `rio.Table` column padding too wide since v0.7.5 #30

Closed joegilkes closed 4 months ago

joegilkes commented 4 months ago

Describe the bug

Following on from a conversation on Discord with @Aran-Fey yesterday, since v0.7.5 was released (which fixed rio.Table not resizing vertically when updated with new data) all rio.Tables now seem to use a much greater horizontal column padding to push the columns apart, sometimes to the edges of the browser window.

Expected Behavior

When building a rio.Table, a sensible horizontal padding between table columns should be chosen to not spread the table over the entire width of its container, as was the case in v0.7.4.

Steps to Reproduce

On Rio v0.7.4, create a project with the following __init__.py:

from __future__ import annotations

from pathlib import Path
from typing import *  # type: ignore    s

import rio

class RootPage(rio.Component):
    def build(self) -> rio.Component:
        return rio.Column(
            rio.Table(
                {f'Col{i}': [i+1, i+2, i+3] for i in range(10)},
                show_row_numbers=False
            ),
            spacing=2,
            width=60,
            margin_bottom=4,
            align_x=0.5,
            align_y=0,
        )

app = rio.App(
    name='Table_MWE',
    pages=[
        rio.Page(
            name="Home",
            page_url='',
            build=RootPage,
        )
    ]
)

Use rio run to visualise the built site. The table will sensibly space out its columns, as in the first screenshot (rio_mwe_074)

Update Rio to v0.75 or newer (I'm now on v0.7.7) and visualise the site with rio run. The columns of the table will now be pushed apart as in the second screenshot (rio_mwe_077), resulting in a stretched table that becomes difficult to read with longer string values in its fields.

Screenshots/Videos

rio_mwe_074 rio_mwe_077

Operating System

Linux

What browsers are you seeing the problem on?

Chrome

Browser version

124.0.6367.201

What device are you using?

Desktop

Additional context

No response

Aran-Fey commented 4 months ago

Thanks for the bug report. It's fixed in 0.7.8.