Skip to content

Commit

Permalink
Minor changes to dynamic components
Browse files Browse the repository at this point in the history
  • Loading branch information
emilhe authored Sep 25, 2023
1 parent 840832a commit 0236a6f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions dash_extensions/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
_original_register_page = dash.register_page


def _register_page(*args, components=None, **kwargs):
def _register_page(*args, dynamic_components=None, **kwargs):
_original_register_page(*args, **kwargs)
if components is None:
if dynamic_components is None:
return
module = kwargs['module'] if 'module' in kwargs else args[0]
page = dash.page_registry[module]
for component in components:
for component in dynamic_components:
set_visible(component, page['path'])


Expand Down Expand Up @@ -83,6 +83,7 @@ def _prepare_container(container: Optional[Component] = None):


def _setup_callbacks():
store = dash.dash._ID_STORE
location = dash.dash._ID_LOCATION
components = list(_PATH_REGISTRY.keys())
for component in components:
Expand All @@ -92,7 +93,9 @@ def _setup_callbacks():
container = _prepare_container(_CONTAINER_REGISTRY.get(component, _COMPONENT_CONTAINER))
container.children.append(wrapper)
# Setup callback.
f = f"function(x){{const paths = {_PATH_REGISTRY[component]}; return !paths.includes(x);}}"
clientside_callback(f, Output(wrapper, "hidden"), Input(location, "pathname"))
f = f"function(y, x){{const paths = {_PATH_REGISTRY[component]}; return !paths.includes(x);}}"
clientside_callback(f, Output(wrapper, "hidden"),
Input(store, "data"),
State(location, "pathname"))

# endregion

0 comments on commit 0236a6f

Please sign in to comment.