Skip to content

Triggers interrupting Chat Value #2368

Open
@mtanco

Description

@mtanco

Wave SDK Version, OS

Wave 1.1.1
Apple M3 Max Sonoma 14.1 (also seen on a Windows machine)
Safari (also tested in Chrome)

Actual behavior

When users type into a chatbot but do not click enter, and then interact with another element, the Submitted element is incorrect.

Expected behavior

Users can type into a chatbot, do other stuff, and then submit later and the chatbot knows it was submitted.

Steps To Reproduce

While running the following app:

  1. type into the chatbot but do not submit
  2. Click the filter button to open the side panel which has a trigger element.
  3. Click away from the side panel to close it - do not click on the trigger element.
  4. Click submit on the chatbot.

The value of __wave_submission_name__ will be the trigger element instead of the chatbot.

from h2o_wave import main, app, Q, ui, data, on, run_on


@app('/')
async def serve(q: Q):

    if not q.client.initialize:

        q.page["meta"] = ui.meta_card("")
        q.page["filter"] = ui.form_card(
            box="6 1 1 1",
            items=[ui.button(name="filter_button", label="Click Me!", primary=True)]
        )
        q.page['chatbot_card'] = ui.chatbot_card(
            box='1 1 5 5',
            name='chatbot',
            data=data(fields='content from_user', t='list', rows=[q.client.chat_history]),
        )

        q.client.agency_list = ["test1", "test2"]
        q.client.selected_agency = None

        q.client.initialize = True

    if q.args.filter_button:
        # The user wants to do some filtering
        q.page["meta"].side_panel = ui.side_panel(
            title="Filter",
            items=[
                ui.choice_group(
                    name="agency_filter", label="Agency Filter",
                    choices=[ui.choice(a, a) for a in q.client.agency_list],
                    value=q.client.selected_agency, trigger=True
                ),
            ]
        )

    if q.args.agency_filter:
        # This is on a trigger and calls when someone has clicked any agency option
        q.client.selected_agency = q.args.agency_filter
        q.page["meta"].notification_bar = ui.notification_bar(
            text="Your option was saved!"
        )

    if q.args.__wave_submission_name__ == "chatbot":
        q.page['chatbot_card'].data += ["👤" + q.args.chatbot, True]
        q.page['chatbot_card'].data += ["🤖 I am just a demo", False]

    await q.page.save()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug in codeuiRelated to UI

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions