Unexpected behavior with bindable dataclass and input inside a dialog #4860
-
First Check
Example Codefrom nicegui import binding, ui
@binding.bindable_dataclass
class Data:
text: str
data = Data(text="some text")
with ui.dialog() as dialog, ui.card():
ui.input(label="Text").bind_value(data, "text")
ui.button(
text="Save",
on_click=dialog.close,
)
ui.label().bind_text_from(data, "text")
ui.button(text="Update text", on_click=dialog.open) DescriptionThe code example is intended to replicate a page where ui elements are bound to a NiceGUI bindable dataclass. I expect the input value inside the dialog to reflect the updated text when the dialog is reopened after a prior save (and dialog close), but the input value displays the original value (pre-update) when the dialog is reopened. If you remove the dialog from this example, the input value retains the updated entry after clicking the save button. Perhaps, I have overlooked a dialog or input property that needs to be set in order to get the expected behavior. For example, maybe the dialog element resets to its original state on close by default or something like that. However, I searched the documentation and did not find anything that would appear to be related to the behavior observed here. Thanks in advance for any help. How to reproduce the unexpected behavior: NiceGUI Version2.19.0 Python Version3.12.10 BrowserFirefox Operating SystemWindows Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @benvc, Unfortunately this is a known bug which we still don't know how to solve: #2149 input_ = ui.input(label='Text').bind_value(data, 'text')
input_.LOOPBACK = True |
Beta Was this translation helpful? Give feedback.
Hi @benvc,
Unfortunately this is a known bug which we still don't know how to solve: #2149
As a workaround you can set
LOOPBACK = True
: