h2oai / wave

Realtime Web Apps and Dashboards for Python and R
https://wave.h2o.ai
Apache License 2.0
3.9k stars 323 forks source link

bug: handle_on behaviour has been changed with Wave 1.0.0 #2335

Closed dulajra closed 3 weeks ago

dulajra commented 1 month ago

Wave SDK Version, OS

Wave 1.0.0 and Wave 1.2.0

Actual behavior

Behavior with Wave 1.2.0

https://github.com/h2oai/wave/assets/12434380/dc02b9e7-cf52-4c92-a8ca-5310a0df2350

Expected behavior

Behavior with Wave 0.26.4

https://github.com/h2oai/wave/assets/12434380/fac91a85-3ae8-4a92-ad5a-be7443cc4f0f

Steps To Reproduce

from h2o_wave import app, handle_on, main, Q, ui, on

@on()
async def submit(q: Q):
    q.page["message"] = ui.form_card(
        box="1 6 5 1",
        items=[
            ui.message_bar("info", "Submit")
        ]
    )

@on()
async def my_table(q: Q):
    q.page["message"] = ui.form_card(
        box="1 6 5 1",
        items=[
            ui.message_bar("info", f"Table: {q.args.my_table}")
        ]
    )

def setup(q: Q):
    q.page["body"] = ui.form_card(
        box="1 1 5 5",
        items=[
            ui.button(name="submit", label="Submit"),
            ui.table(
                name="my_table",
                columns=[
                    ui.table_column("column_1", "Column 1"),
                    ui.table_column("column_2", "Column 2"),
                ],
                rows=[
                    ui.table_row(name="row_1", cells=["Row 1 Cell 1", "Row 1 Cell 2"]),
                    ui.table_row(name="row_2", cells=["Row 2 Cell 1", "Row 2 Cell 2"]),
                ]
            )
        ]
    )

@app("/")
async def serve(q: Q) -> None:
    print(f"submit: {q.args.submit}")
    print(f"my_table: {q.args.my_table}")

    if not await handle_on(q):
        setup(q)

    await q.page.save()
mturoci commented 1 month ago

Replacing handle_on with run_on gets you the expected behavior. Any other behavior change?

dulajra commented 1 month ago

Replacing handle_on with run_on gets you the expected behavior. Any other behavior change?

I will check. But that means the handle_on has been broken with Wave 1.0.0? So the option 2 we discussed on slack won't work anyway.

mturoci commented 1 month ago

Well, if this is the only problem with handle_on, then the migration should be smooth. If not, you need to identify the rest of the cases so that we do not end up in a situation where 1 case is fixed, but the app will not work anyway.