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

Binding is not reapplied correctly in ui.stepper() #1638

Closed
rodja opened this issue Sep 17, 2023 · 3 comments
Closed

Binding is not reapplied correctly in ui.stepper() #1638

rodja opened this issue Sep 17, 2023 · 3 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@rodja
Copy link
Member

rodja commented Sep 17, 2023

Description

Consider this code:

name = 'Bob'

with ui.stepper().classes('w-96') as stepper:
    with ui.step('Set name'):
        ui.input('Name').bind_value(globals(), 'name')

        with ui.stepper_navigation():
            ui.button('Next', on_click=stepper.next)

    with ui.step('Show name'):
        ui.label().bind_text_from(globals(), 'name')
        with ui.stepper_navigation():
            ui.button('Back', on_click=stepper.previous)

ui.timer(1, lambda: print(name))

On first start the name input is correctly filled with "Bob". If the name is changed via the input field the changed value is printed to the console. Also on the next step the value is correctly shown. But when pressing "Back" the input field shows the value "Bob" again. I would expect it to be the value I've typed in earlier (and which is still printed on the console).

I now this can be fixed by setting the keep-alive prop on the stepper. But then I do not need the binding at all because the elements will be reused.

@rodja rodja added the bug Something isn't working label Sep 17, 2023
@falkoschindler
Copy link
Contributor

I think we can eliminate binding from the reproduction:

name = 'Bob'

with ui.stepper() as stepper:
    with ui.step('Set name'):
        ui.input('Name', value=name, on_change=lambda e: globals().update(name=e.value))
        ui.button('Next', on_click=stepper.next)
    with ui.step('Done'):
        ui.button('Back', on_click=stepper.previous)

ui.timer(1, lambda: print(name))

@falkoschindler
Copy link
Contributor

Ok, we agreed to introduce a keep-alive parameter for ui.stepper like we did for ui.tab_panels.

@falkoschindler falkoschindler added this to the 1.3.14 milestone Sep 18, 2023
@falkoschindler falkoschindler self-assigned this Sep 18, 2023
@rodja
Copy link
Member Author

rodja commented Sep 18, 2023

Side note: the issue was uncovered while trying to answer a question over on Discord.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants