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

Fix: No input argument makes the app unresponsive #57

Merged
merged 2 commits into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions fast_dash/Components.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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

Expand Down
25 changes: 15 additions & 10 deletions fast_dash/fast_dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
theme_mapper,
_infer_variable_names,
_parse_docstring_as_markdown,
_get_error_notification_component
_get_error_notification_component,
)


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
Loading