h2oai / h2oai/wave

Possible bug when updating existing components

Open
#2,381 0 comments 0 reactions 0 assignees View on GitHub
bug py
Dominant language
Python
Stars
4.3k
Forks
371
Avg merge
26d 1h
Merged PRs (30d)
1

Description

#### 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

```python
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()

```

Contributor guide

Open the contributing guide

Research direction

Start with the Python reproduction and the q.page component and items access patterns shown in the issue. Reproduce the update of textbox3 after textbox1 or textbox2 submits, then trace why direct value and label changes do not persist while replacing items[3] does. Done means updating the existing component changes both its value and label without recreating it.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.