h2oai / h2oai/wave

By-name component access not working for updated items

Open
#2,210 0 comments 0 reactions 1 assignee Claimed by @mturoci View on GitHub
bug
Dominant language
Python
Stars
4.3k
Forks
371
Avg merge
26d 1h
Merged PRs (30d)
1

Description

#### Wave SDK Version, OS

Wave v1.0.0, MacOS 13.5.1, Chrome Version 119.0.6045.159 (Official Build) (arm64)

#### Actual behavior

Unable to update components using by-name component access inside the `items` which were previously updated.

https://github.com/h2oai/wave/assets/23740173/c8c80df0-8892-44c8-a62f-e207d78f12f5

#### Expected behavior

Form text content is updated when clicking on the **Clear** button.

#### Steps To Reproduce

Repro code:
```py
from h2o_wave import main, app, Q, ui

def get_form_items(clicked: str):
return [
ui.text(content='The quick brown [fox](?fox) jumps over the lazy [dog](?dog)'),
ui.text(name='text_clicked', content=f'Clicked: {clicked}'),
ui.button(name='clear', label='Clear'),
]

@app('/demo')
async def serve(q: Q):
if not q.client.initialized:
q.page['example'] = ui.form_card(box='1 1 3 2', items=get_form_items('Nothing'))
q.client.initialized = True

if q.args.fox:
q.page['example'].items = get_form_items('fox')
if q.args.dog:
q.page['example'].items = get_form_items('dog')
if q.args.clear:
# Working
# q.page['example'].items[1].text.content = 'Clicked:'
# Not working
q.page['example'].text_clicked.content = 'Clicked:'
await q.page.save()
```

1. Click the **Clear** button - sets the content properly.
2. Click on _fox_ or _dog_ to update form `items`.
3. Click the **Clear** button again.
4. It does not set the content.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.