Skip to content

Weird behavior of select #2643

Closed
Closed
@me21

Description

Description

Consider the following code:

@ui.page('/test', title='Test page')
async def setup_test_page():
    data = {'test_value': 'option 1'}
    async def open_dialog():
        with ui.dialog() as dialog, ui.card():
            ui.select(['option 1'], validation={'This field is required': bool}, new_value_mode='add-unique').bind_value(data, 'test_value')
            ui.button('OK', on_click=lambda: dialog.submit('OK'))
            ui.button('Cancel', on_click=lambda: dialog.submit('Cancel'))
        result = await dialog
        if result == 'Cancel':
            print('Resetting test_value to \'option 1\'.')
            data['test_value'] = 'option 1'

    ui.button('Open dialog', on_click=open_dialog)
    ui.timer(callback=lambda: print(f'Test value: {data["test_value"]}'), interval=1)

Maybe it can be minimized further, I'm not sure.

To reproduce, click on the button, then press Tab to focus on the select, enter "fizz" there, press Tab again, then Cancel. So far so good.
Now click on the button again, press Tab, enter "buzz", press Tab again. You will get a "This field is required" error. What's going on?

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions