From 9699faf44fb109ea8820e0a58fc6d3a30ebf529a Mon Sep 17 00:00:00 2001 From: Kedar Dabhadkar Date: Fri, 15 Dec 2023 19:18:36 -0500 Subject: [PATCH] Fix: No input argument makes the app unresponsive --- fast_dash/Components.py | 6 ++++-- fast_dash/fast_dash.py | 25 +++++++++++++++---------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/fast_dash/Components.py b/fast_dash/Components.py index ad7f216..7d8fd6f 100644 --- a/fast_dash/Components.py +++ b/fast_dash/Components.py @@ -266,6 +266,7 @@ def generate_layout(self): layout = dbc.Container( [ + html.Div(id="dummy-div", style={"display": "none"}), self.generate_navbar_container(), self.generate_header_component(), dbc.Row( @@ -640,6 +641,7 @@ def generate_layout(self): layout = dmc.MantineProvider( dmc.NotificationsProvider( [ + html.Div(id="dummy-div", style={"display": "none"}), dbc.Container( [ self.generate_navbar_container(), @@ -672,10 +674,10 @@ def generate_layout(self): def callbacks(self, app): @app.app.callback( [Output("input-group", "style"), Output("sidebar-button", "opened")], - [Input("sidebar-button", "opened"), Input("submit_inputs", "n_clicks")], + [Input("sidebar-button", "opened")], [State("input-group", "style")], ) - def toggle_sidebar(opened, submit_clicks, input_style): + def toggle_sidebar(opened, input_style): user_agent = request.headers.get("User-Agent") input_style = {} if input_style is None else input_style diff --git a/fast_dash/fast_dash.py b/fast_dash/fast_dash.py index ca15956..8ee4b3d 100644 --- a/fast_dash/fast_dash.py +++ b/fast_dash/fast_dash.py @@ -26,7 +26,7 @@ theme_mapper, _infer_variable_names, _parse_docstring_as_markdown, - _get_error_notification_component + _get_error_notification_component, ) @@ -178,7 +178,9 @@ def __init__( self.subtitle = ( subheader if subheader is not None - else _parse_docstring_as_markdown(callback_fn, title=self.title, get_short=True) + else _parse_docstring_as_markdown( + callback_fn, title=self.title, get_short=True + ) ) self.github_url = github_url self.linkedin_url = linkedin_url @@ -253,9 +255,7 @@ def __init__( self.server = self.app.server def run(self): - self.app.run( - **self.run_kwargs - ) if self.mode is None else self.app.run_server( + self.app.run(**self.run_kwargs) if self.mode is None else self.app.run_server( jupyter_mode=self.mode, **self.run_kwargs ) @@ -323,7 +323,10 @@ def register_callback_fn(self): prevent_initial_callback=True, ) def process_input(*args): - if ctx.triggered_id not in ["submit_inputs", "reset_inputs"]: + if ( + ctx.triggered_id not in ["submit_inputs", "reset_inputs"] + and self.update_live is False + ): raise PreventUpdate default_notification = None @@ -377,20 +380,22 @@ def process_input(*args): component_property=input_.ack.component_property, ) for input_ in self.inputs_with_ids - ], + ] + + [Output("dummy-div", "children")], [ Input( component_id=input_.id, component_property=input_.component_property ) for input_ in self.inputs_with_ids - ], + ] + + [Input("dummy-div", "children")], ) def process_ack_outputs(*args): ack_components = [ ack if mask is True else None - for mask, ack in zip(self.ack_mask, list(args)) + for mask, ack in zip(self.ack_mask, list(args)[:-1]) ] - return ack_components + return ack_components + [[]] # Set layout callbacks if not self.minimal: