Skip to content

Commit 9d29023

Browse files
committed
Reset the user interface when the browser is refreshed
1 parent 75c33de commit 9d29023

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

examples/form_disabling/view.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from nova.trame import ThemedApp
55
from nova.trame.view.components import InputField
66
from nova.trame.view.layouts import VBoxLayout
7+
from trame.widgets import client
78
from trame.widgets import vuetify3 as vuetify
89

910
from .model import Model
@@ -25,6 +26,12 @@ def __init__(self) -> None:
2526

2627
def create_ui(self) -> None:
2728
with super().create_ui() as layout:
29+
# This instructs the user interface to reset itself to the most recent valid state when a browser connects
30+
# to the tool or the browser is refreshed. This is not appropriate for all situations, so it is not a
31+
# default behavior at this time. You can disable this line and then refresh your browser while the user
32+
# interface is in an error state to see the difference between the two behaviors.
33+
client.ClientTriggers(mounted=self.view_model.init_view)
34+
2835
with layout.pre_content:
2936
vuetify.VBanner(
3037
"The form is in an error state.",

examples/form_disabling/view_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def update_view_state(self) -> None:
4747
self.view_state_bind.update_in_view(self.view_state)
4848

4949
def init_view(self) -> None:
50-
self.view_state.has_errors = False
50+
self.view_state.errors = []
5151

5252
self.update_form_data()
5353
self.update_view_state()

0 commit comments

Comments
 (0)