[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible bug when updating existing components #2381

Open
pascal-pfeiffer opened this issue Aug 9, 2024 · 0 comments
Open

Possible bug when updating existing components #2381

pascal-pfeiffer opened this issue Aug 9, 2024 · 0 comments
Labels
bug Bug in code py Related to Python Driver

Comments

@pascal-pfeiffer
Copy link
pascal-pfeiffer commented Aug 9, 2024

Wave SDK Version, OS

wave 1.3.4

Actual behavior

Given the small demo code below, I don't seem to be able to update the value of textbox3 without recreating the item
In my interpretation of the description of #1870, the code below should work.

Expected behavior

Ability to update the value and label of textbox3

Steps To Reproduce

from h2o_wave import Q, copy_expando, ui, main, app  # noqa: 401


async def meta(q: Q) -> None:
    q.page["meta"] = ui.meta_card(
        box="",
        title="my app",
        layouts=[
            ui.layout(
                breakpoint="0px",
                width="100%",
                zones=[
                    ui.zone(
                        "content",
                        size="1",
                    ),
                ],
            ),
        ],
        script=None,
        notification_bar=None,
    )

    q.page["meta"].theme = "h2o-dark"


@app("/")
async def serve(q: Q):
    print(q.args)
    copy_expando(q.args, q.client)

    q.page["my_important_content"] = ui.form_card(box="content", items=[])

    items = [
        ui.text_l("Cool headline"),
        ui.textbox(
            name="textbox1",
            label="Value1",
            value=q.client["textbox1"],
            trigger=True,
            required=True,
        ),
        ui.textbox(
            name="textbox2",
            label="Value2",
            value=q.client["textbox2"],
            trigger=True,
            required=True,
        ),
    ]

    items_exp = items + [
        ui.textbox(
            name="textbox3",
            label="Concatenated values",
            value=q.client["textbox3"],
            disabled=True,
        ),
    ]

    q.page["my_important_content"].items = items_exp

    if q.args.__wave_submission_name__ == "home":
        q.client["nav/active"] = "home"
    elif q.args.__wave_submission_name__ == "settings":
        q.client["nav/active"] = "settings"

    if (
        q.args.__wave_submission_name__ == "textbox1"
        or q.args.__wave_submission_name__ == "textbox2"
    ):
        print("updating the page")
        new_value = q.client["textbox1"] + q.client["textbox2"]
        print(new_value)

        # these both don't do anything
        q.page["my_important_content"].textbox3.value = new_value
        q.page["my_important_content"].textbox3.label = new_value

        # these both don't do anything
        q.page["textbox3"].value = new_value
        q.page["textbox3"].label = new_value

        # these both don't do anything
        q.page["content"].textbox3.value = new_value
        q.page["content"].textbox3.label = new_value

        # these both don't do anything
        q.page["meta"].textbox3.value = new_value
        q.page["meta"].textbox3.label = new_value

        # removes the item
        q.page["my_important_content"].items[3].label = new_value

        # does nothing
        q.page["my_important_content"].items[3].value = new_value

        # This removes the component
        q.page["my_important_content"].items.textbox3 = ui.textbox(
            name="textbox3",
            label="Concatenated values",
            value=new_value,
            disabled=True,
        )

        # This removes the component
        q.page["my_important_content"].items["textbox3"] = ui.textbox(
            name="textbox3",
            label="Concatenated values",
            value=new_value,
            disabled=True,
        )

        # This removes the component
        q.page["my_important_content"].textbox3 = ui.textbox(
            name="textbox3",
            label="Concatenated values",
            value=new_value,
            disabled=True,
        )

        # This works
        q.page["my_important_content"].items[3] = ui.textbox(
            name="textbox3",
            label="Concatenated values",
            value=new_value,
            disabled=True,
        )

        # This works
        items_exp = items + [
            ui.textbox(
                name="textbox3",
                label="Concatenated values",
                value=new_value,
                disabled=True,
            ),
        ]
        q.page["my_important_content"].items = items_exp

    await meta(q)

    await q.page.save()
@pascal-pfeiffer pascal-pfeiffer added the bug Bug in code label Aug 9, 2024
@mturoci mturoci added the py Related to Python Driver label Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug in code py Related to Python Driver
Projects
None yet
Development

No branches or pull requests

2 participants