From 4523f2f704e91f4af3684181adf673b24891af99 Mon Sep 17 00:00:00 2001 From: nadijagraca <108531476+nadijagraca@users.noreply.github.com> Date: Thu, 4 Jan 2024 12:31:57 +0100 Subject: [PATCH 1/9] Bug fix on update nested graph properties (#237) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: huong-li-nguyen --- CODEOWNERS | 2 +- ...619_nadija_ratkusic_graca_parameter_bug.md | 47 +++++++++++++++ vizro-core/docs/pages/development/authors.md | 1 + .../src/vizro/actions/_actions_utils.py | 8 ++- .../unit/vizro/actions/test_actions_utils.py | 59 +++++++++++++------ 5 files changed, 96 insertions(+), 21 deletions(-) create mode 100644 vizro-core/changelog.d/20231222_112619_nadija_ratkusic_graca_parameter_bug.md diff --git a/CODEOWNERS b/CODEOWNERS index d44ff609d..ebd943bcf 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1 +1 @@ -* @Joseph-Perkins @antonymilne @huong-li-nguyen @maxschulz-COL @lingyielia +* @Joseph-Perkins @antonymilne @huong-li-nguyen @maxschulz-COL diff --git a/vizro-core/changelog.d/20231222_112619_nadija_ratkusic_graca_parameter_bug.md b/vizro-core/changelog.d/20231222_112619_nadija_ratkusic_graca_parameter_bug.md new file mode 100644 index 000000000..db100622e --- /dev/null +++ b/vizro-core/changelog.d/20231222_112619_nadija_ratkusic_graca_parameter_bug.md @@ -0,0 +1,47 @@ + + + + + + + + +### Fixed + +- Fix a bug that prevented the update of nested graph properties through parameters when the graph property was not previously defined. ([#273](https://github.com/mckinsey/vizro/pull/237)) + + diff --git a/vizro-core/docs/pages/development/authors.md b/vizro-core/docs/pages/development/authors.md index 394dd54ac..43d1c5f00 100644 --- a/vizro-core/docs/pages/development/authors.md +++ b/vizro-core/docs/pages/development/authors.md @@ -14,6 +14,7 @@ ## Previous team members and code contributors +[Ann Marie Ward](https://github.com/AnnMarieW), [Ned Letcher](https://github.com/ned2), Natalia Kurakina, [Leon Nallamuthu](https://github.com/leonnallamuthu), diff --git a/vizro-core/src/vizro/actions/_actions_utils.py b/vizro-core/src/vizro/actions/_actions_utils.py index ea0a1ef29..eb65f378f 100644 --- a/vizro-core/src/vizro/actions/_actions_utils.py +++ b/vizro-core/src/vizro/actions/_actions_utils.py @@ -174,11 +174,15 @@ def _create_target_arg_mapping(dot_separated_strings: List[str]) -> Dict[str, Li return results -def _update_nested_graph_properties(graph_config: Dict[str, Any], dot_separated_string: str, value: Any): +def _update_nested_graph_properties( + graph_config: Dict[str, Any], dot_separated_string: str, value: Any +) -> Dict[str, Any]: keys = dot_separated_string.split(".") current_property = graph_config + for key in keys[:-1]: - current_property = current_property[key] + current_property = current_property.setdefault(key, {}) + current_property[keys[-1]] = value return graph_config diff --git a/vizro-core/tests/unit/vizro/actions/test_actions_utils.py b/vizro-core/tests/unit/vizro/actions/test_actions_utils.py index 101018566..56e09f899 100644 --- a/vizro-core/tests/unit/vizro/actions/test_actions_utils.py +++ b/vizro-core/tests/unit/vizro/actions/test_actions_utils.py @@ -3,11 +3,6 @@ from vizro.actions._actions_utils import _create_target_arg_mapping, _update_nested_graph_properties -@pytest.fixture -def fake_graph_property_dict(): - return {"nodes": {"A": {"color": "blue"}, "B": {"color": "green"}}} - - class TestUpdateNestedGraphProperties: def test_update_nested_graph_properties_single_level(self): graph = {"color": "blue"} @@ -15,26 +10,54 @@ def test_update_nested_graph_properties_single_level(self): expected = {"color": "red"} assert result == expected - def test_update_nested_graph_properties_multiple_levels(self): - graph = {"node": {"label": "A", "color": "blue"}} - result = _update_nested_graph_properties(graph, "node.color", 2) - expected = {"node": {"label": "A", "color": 2}} + @pytest.mark.parametrize( + "graph, dot_separated_strings, value, expected", + [ + ({"node": {"label": "A", "color": "blue"}}, "node.color", "red", {"node": {"label": "A", "color": "red"}}), + ( + {"nodes": {"A": {"color": "blue"}, "B": {"color": "green"}}}, + "nodes.A.color", + "red", + {"nodes": {"A": {"color": "red"}, "B": {"color": "green"}}}, + ), + ], + ) + def test_update_nested_graph_properties_multiple_levels(self, graph, dot_separated_strings, value, expected): + result = _update_nested_graph_properties(graph, dot_separated_strings, value) assert result == expected - def test_update_nested_graph_properties_nested_dict(self): - graph = {"nodes": {"A": {"color": "blue"}, "B": {"color": "green"}}} - result = _update_nested_graph_properties(graph, "nodes.A.color", "red") - expected = {"nodes": {"A": {"color": "red"}, "B": {"color": "green"}}} + @pytest.mark.parametrize( + "graph, dot_separated_strings, value, expected", + [ + ( + {"nodes": {"A": {"color": "blue"}, "B": {"color": "green"}}}, + "nodes.C.color", + "red", + {"nodes": {"A": {"color": "blue"}, "B": {"color": "green"}, "C": {"color": "red"}}}, + ), + ( + {"nodes": {"A": {"color": "blue"}, "B": {"color": "red"}}}, + "nodes.B.value", + "red", + {"nodes": {"A": {"color": "blue"}, "B": {"color": "red", "value": "red"}}}, + ), + ( + {"nodes": {"A": {"color": "blue"}, "B": {"color": "green"}}}, + "nodes.B", + "red", + {"nodes": {"A": {"color": "blue"}, "B": "red"}}, + ), + ({}, "color", "red", {"color": "red"}), + ], + ) + def test_update_nested_graph_properties_add_or_overwrite_keys(self, graph, dot_separated_strings, value, expected): + result = _update_nested_graph_properties(graph, dot_separated_strings, value) assert result == expected - def test_update_nested_graph_properties_invalid_key(self, fake_graph_property_dict): - with pytest.raises(KeyError, match="C"): - _update_nested_graph_properties(fake_graph_property_dict, "nodes.C.color", "red") - def test_update_nested_graph_properties_invalid_type(self): graph = {"color": "blue"} with pytest.raises(TypeError, match="'str' object does not support item assignment"): - _update_nested_graph_properties(graph, "color.value", 42) + _update_nested_graph_properties(graph, "color.value", "42") class TestCreateTargetArgMapping: From 37155be9b3ad3b9c273006331345d30aed4c504b Mon Sep 17 00:00:00 2001 From: huong-li-nguyen Date: Wed, 3 Jan 2024 16:17:21 +0100 Subject: [PATCH 2/9] Replace toggle switch --- vizro-core/pyproject.toml | 1 - vizro-core/snyk/requirements.txt | 1 - .../actions/_callback_mapping/_callback_mapping_utils.py | 2 +- vizro-core/src/vizro/models/_dashboard.py | 8 ++++---- vizro-core/src/vizro/models/_page.py | 2 +- .../_callback_mapping/test_get_action_callback_mapping.py | 2 +- vizro-core/tests/unit/vizro/actions/test_filter_action.py | 4 ++-- .../unit/vizro/actions/test_filter_interaction_action.py | 2 +- .../tests/unit/vizro/actions/test_on_page_load_action.py | 2 +- .../tests/unit/vizro/actions/test_parameter_action.py | 6 +++--- .../tests/unit/vizro/models/_components/test_graph.py | 2 +- 11 files changed, 15 insertions(+), 17 deletions(-) diff --git a/vizro-core/pyproject.toml b/vizro-core/pyproject.toml index b80fcee7f..72a3d8a53 100644 --- a/vizro-core/pyproject.toml +++ b/vizro-core/pyproject.toml @@ -22,7 +22,6 @@ dependencies = [ "dash_bootstrap_components", "pandas", "pydantic>=1.10.13", # must be synced with pre-commit mypy hook manually - "dash_daq", "dash_mantine_components", "ipython>=8.10.0", # not directly required, pinned by Snyk to avoid a vulnerability: https://app.snyk.io/vuln/SNYK-PYTHON-IPYTHON-3318382 "numpy>=1.22.2", # not directly required, pinned by Snyk to avoid a vulnerability: https://security.snyk.io/vuln/SNYK-PYTHON-NUMPY-2321970 diff --git a/vizro-core/snyk/requirements.txt b/vizro-core/snyk/requirements.txt index 4bf9a9c93..b2f8099a4 100644 --- a/vizro-core/snyk/requirements.txt +++ b/vizro-core/snyk/requirements.txt @@ -2,7 +2,6 @@ dash>=2.14.1 dash_bootstrap_components pandas pydantic>=1.10.13 -dash_daq dash_mantine_components ipython>=8.10.0 numpy>=1.22.2 diff --git a/vizro-core/src/vizro/actions/_callback_mapping/_callback_mapping_utils.py b/vizro-core/src/vizro/actions/_callback_mapping/_callback_mapping_utils.py index a8fae095a..2f14429b8 100644 --- a/vizro-core/src/vizro/actions/_callback_mapping/_callback_mapping_utils.py +++ b/vizro-core/src/vizro/actions/_callback_mapping/_callback_mapping_utils.py @@ -154,7 +154,7 @@ def _get_action_callback_inputs(action_id: ModelID) -> Dict[str, Any]: if "filter_interaction" in include_inputs else [] ), - "theme_selector": State("theme_selector", "on") if "theme_selector" in include_inputs else [], + "theme_selector": State("theme_selector", "checked") if "theme_selector" in include_inputs else [], } return action_input_mapping diff --git a/vizro-core/src/vizro/models/_dashboard.py b/vizro-core/src/vizro/models/_dashboard.py index a5c3736ef..785563a35 100644 --- a/vizro-core/src/vizro/models/_dashboard.py +++ b/vizro-core/src/vizro/models/_dashboard.py @@ -7,7 +7,7 @@ import dash import dash_bootstrap_components as dbc -import dash_daq as daq +import dash_mantine_components as dmc from dash import ClientsideFunction, Input, Output, clientside_callback, get_relative_path, html try: @@ -115,7 +115,7 @@ def build(self): clientside_callback( ClientsideFunction(namespace="clientside", function_name="update_dashboard_theme"), Output("dashboard_container_outer", "className"), - Input("theme_selector", "on"), + Input("theme_selector", "checked"), ) return html.Div( @@ -135,8 +135,8 @@ def _get_page_divs(self, page: Page) -> _PageDivsType: ) settings = html.Div( - daq.BooleanSwitch( - id="theme_selector", on=self.theme == "vizro_dark", persistence=True, persistence_type="session" + dmc.Switch( + id="theme_selector", checked=self.theme == "vizro_dark", persistence=True, persistence_type="session", className="toggle-switch" ), id="settings", ) diff --git a/vizro-core/src/vizro/models/_page.py b/vizro-core/src/vizro/models/_page.py index 4a24538b5..ad03048fd 100644 --- a/vizro-core/src/vizro/models/_page.py +++ b/vizro-core/src/vizro/models/_page.py @@ -163,7 +163,7 @@ def _update_graph_theme(self): @callback( [Output(component.id, "figure", allow_duplicate=True) for component in themed_components], - Input("theme_selector", "on"), + Input("theme_selector", "checked"), prevent_initial_call="initial_duplicate", ) def update_graph_theme(theme_selector: bool): diff --git a/vizro-core/tests/unit/vizro/actions/_callback_mapping/test_get_action_callback_mapping.py b/vizro-core/tests/unit/vizro/actions/_callback_mapping/test_get_action_callback_mapping.py index 36f29957c..10641e63a 100644 --- a/vizro-core/tests/unit/vizro/actions/_callback_mapping/test_get_action_callback_mapping.py +++ b/vizro-core/tests/unit/vizro/actions/_callback_mapping/test_get_action_callback_mapping.py @@ -127,7 +127,7 @@ def action_callback_inputs_expected(): "derived_viewport_data": dash.State("underlying_table_id", "derived_viewport_data"), }, ], - "theme_selector": dash.State("theme_selector", "on"), + "theme_selector": dash.State("theme_selector", "checked"), } diff --git a/vizro-core/tests/unit/vizro/actions/test_filter_action.py b/vizro-core/tests/unit/vizro/actions/test_filter_action.py index 5a0ff2e41..3e4cb3217 100644 --- a/vizro-core/tests/unit/vizro/actions/test_filter_action.py +++ b/vizro-core/tests/unit/vizro/actions/test_filter_action.py @@ -49,7 +49,7 @@ def callback_context_filter_continent(request): "parameters": [], "theme_selector": CallbackTriggerDict( id="theme_selector", - property="on", + property="checked", value=True, str_id="theme_selector", triggered=False, @@ -88,7 +88,7 @@ def callback_context_filter_continent_and_pop(request): "parameters": [], "theme_selector": CallbackTriggerDict( id="theme_selector", - property="on", + property="checked", value=True, str_id="theme_selector", triggered=False, diff --git a/vizro-core/tests/unit/vizro/actions/test_filter_interaction_action.py b/vizro-core/tests/unit/vizro/actions/test_filter_interaction_action.py index ceb625ea7..5920584f5 100644 --- a/vizro-core/tests/unit/vizro/actions/test_filter_interaction_action.py +++ b/vizro-core/tests/unit/vizro/actions/test_filter_interaction_action.py @@ -74,7 +74,7 @@ def callback_context_filter_interaction(request): "parameters": [], "theme_selector": CallbackTriggerDict( id="theme_selector", - property="on", + property="checked", value=True, str_id="theme_selector", triggered=False, diff --git a/vizro-core/tests/unit/vizro/actions/test_on_page_load_action.py b/vizro-core/tests/unit/vizro/actions/test_on_page_load_action.py index 5f5ac48f8..2de953dd0 100644 --- a/vizro-core/tests/unit/vizro/actions/test_on_page_load_action.py +++ b/vizro-core/tests/unit/vizro/actions/test_on_page_load_action.py @@ -80,7 +80,7 @@ def callback_context_on_page_load(request): ], "theme_selector": CallbackTriggerDict( id="theme_selector", - property="on", + property="checked", value=template == "vizro_dark", str_id="theme_selector", triggered=False, diff --git a/vizro-core/tests/unit/vizro/actions/test_parameter_action.py b/vizro-core/tests/unit/vizro/actions/test_parameter_action.py index 90e8372ed..a098f99aa 100644 --- a/vizro-core/tests/unit/vizro/actions/test_parameter_action.py +++ b/vizro-core/tests/unit/vizro/actions/test_parameter_action.py @@ -68,7 +68,7 @@ def callback_context_parameter_y(request): ], "theme_selector": CallbackTriggerDict( id="theme_selector", - property="on", + property="checked", value=True, str_id="theme_selector", triggered=False, @@ -100,7 +100,7 @@ def callback_context_parameter_hover_data(request): ], "theme_selector": CallbackTriggerDict( id="theme_selector", - property="on", + property="checked", value=True, str_id="theme_selector", triggered=False, @@ -139,7 +139,7 @@ def callback_context_parameter_y_and_x(request): ], "theme_selector": CallbackTriggerDict( id="theme_selector", - property="on", + property="checked", value=True, str_id="theme_selector", triggered=False, diff --git a/vizro-core/tests/unit/vizro/models/_components/test_graph.py b/vizro-core/tests/unit/vizro/models/_components/test_graph.py index 8d92aed2a..17b1434b5 100644 --- a/vizro-core/tests/unit/vizro/models/_components/test_graph.py +++ b/vizro-core/tests/unit/vizro/models/_components/test_graph.py @@ -115,7 +115,7 @@ def test_update_theme_inside_callback(self, standard_px_chart, template): "external": { "theme_selector": CallbackTriggerDict( id="theme_selector", - property="on", + property="checked", value=template == "vizro_dark", str_id="theme_selector", triggered=False, From c15625560cd36b40d673bb966ce861ee037c3b39 Mon Sep 17 00:00:00 2001 From: huong-li-nguyen Date: Wed, 3 Jan 2024 16:46:16 +0100 Subject: [PATCH 3/9] Fix CSS --- vizro-core/src/vizro/static/css/toggle.css | 59 ++++++++++------------ 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/vizro-core/src/vizro/static/css/toggle.css b/vizro-core/src/vizro/static/css/toggle.css index 98152405f..56d420268 100644 --- a/vizro-core/src/vizro/static/css/toggle.css +++ b/vizro-core/src/vizro/static/css/toggle.css @@ -1,48 +1,43 @@ -/* Toggle Container */ -#theme_selector .jAjsxw { +.toggle-switch { width: 32px; } -/* Toggle */ -#theme_selector .gJuplL, -#theme_selector .cmSQpo { - background: var(--fill-subtle); - border: 1px solid var(--border-enabled); - border-radius: 16px; - display: flex; - flex-shrink: 0; - height: 16px; +#page-container .mantine-Switch-track { + min-width: 32px; width: 32px; + height: 16px; + background-color: var(--fill-subtle); + border-radius: 16px; + border: 1px solid var(--border-enabled); } -#theme_selector .gJuplL:active, -#theme_selector .cmSQpo:active { - background: var(--fill-high-emphasis); +#page-container .mantine-Switch-track:focus { + border: 2px solid var(--focus-focus); } -#theme_selector .gJuplL:focus, -#theme_selector .cmSQpo:focus { - border: 2px solid var(--focus-focus); +#page-container .mantine-Switch-input { + margin: 0; +} + +#page-container .mantine-Switch-trackLabel { + margin: 0; + width: 32px; + height: 16px; } -/* Switch */ -#theme_selector .dlqMgb, -#theme_selector .igrnnx { - background: var(--fill-medium-emphasis); +#page-container .mantine-Switch-thumb { border: none; - border-radius: 10px; - flex-shrink: 0; - height: 10px; - transform: translateX(1px); - width: 10px; + width: 12px; + height: 12px; + background-color: var(--fill-medium-emphasis); } -#theme_selector .igrnnx { - transform: translateX(16px); +#page-container input:checked + * > .mantine-11dx59s { + left: calc(100% - 14px); + background: var(--text-contrast-primary); } -#theme_selector .dlqMgb:active, -#theme_selector .igrnnx:active { - background: var(--fill-contrast-hover-selected); - border: 1px solid var(--border-contrast-selected); +#page-container input:checked + * > .mantine-69c9zd { + background: var(--text-primary); + border-color: var(--border-enabled); } From 90ae23102d801683ea29dd599336988f1419674e Mon Sep 17 00:00:00 2001 From: huong-li-nguyen Date: Wed, 3 Jan 2024 17:02:51 +0100 Subject: [PATCH 4/9] Fix toggle behaviour --- vizro-core/src/vizro/models/_components/graph.py | 2 +- vizro-core/src/vizro/models/_dashboard.py | 6 +++++- vizro-core/src/vizro/static/js/models/dashboard.js | 2 +- vizro-core/tests/js/models/dashboard.test.js | 6 +++--- vizro-core/tests/unit/vizro/actions/test_filter_action.py | 4 ++-- .../tests/unit/vizro/actions/test_on_page_load_action.py | 2 +- .../tests/unit/vizro/actions/test_parameter_action.py | 6 +++--- .../tests/unit/vizro/models/_components/test_graph.py | 2 +- 8 files changed, 17 insertions(+), 13 deletions(-) diff --git a/vizro-core/src/vizro/models/_components/graph.py b/vizro-core/src/vizro/models/_components/graph.py index 40200dd52..03f8e8b58 100644 --- a/vizro-core/src/vizro/models/_components/graph.py +++ b/vizro-core/src/vizro/models/_components/graph.py @@ -102,5 +102,5 @@ def build(self): def _update_theme(fig: go.Figure, theme_selector: bool): # Basically the same as doing fig.update_layout(template="vizro_light/dark") but works for both the call in # self.__call__ and in the update_graph_theme callback. - fig["layout"]["template"] = themes.dark if theme_selector else themes.light + fig["layout"]["template"] = themes.light if theme_selector else themes.dark return fig diff --git a/vizro-core/src/vizro/models/_dashboard.py b/vizro-core/src/vizro/models/_dashboard.py index 785563a35..bf6c1a0d6 100644 --- a/vizro-core/src/vizro/models/_dashboard.py +++ b/vizro-core/src/vizro/models/_dashboard.py @@ -136,7 +136,11 @@ def _get_page_divs(self, page: Page) -> _PageDivsType: settings = html.Div( dmc.Switch( - id="theme_selector", checked=self.theme == "vizro_dark", persistence=True, persistence_type="session", className="toggle-switch" + id="theme_selector", + checked=self.theme == "vizro_light", + persistence=True, + persistence_type="session", + className="toggle-switch", ), id="settings", ) diff --git a/vizro-core/src/vizro/static/js/models/dashboard.js b/vizro-core/src/vizro/static/js/models/dashboard.js index 6a151d1ee..ceddcb510 100644 --- a/vizro-core/src/vizro/static/js/models/dashboard.js +++ b/vizro-core/src/vizro/static/js/models/dashboard.js @@ -1,3 +1,3 @@ export function _update_dashboard_theme(on) { - return on ? "vizro_dark" : "vizro_light"; + return on ? "vizro_light" : "vizro_dark"; } diff --git a/vizro-core/tests/js/models/dashboard.test.js b/vizro-core/tests/js/models/dashboard.test.js index bb193a8c1..9491910df 100644 --- a/vizro-core/tests/js/models/dashboard.test.js +++ b/vizro-core/tests/js/models/dashboard.test.js @@ -1,6 +1,6 @@ import { _update_dashboard_theme } from "../../../src/vizro/static/js/models/dashboard.js"; -test("true returns vizro_dark and false vizro_light", () => { - expect(_update_dashboard_theme(true)).toBe("vizro_dark"); - expect(_update_dashboard_theme(false)).toBe("vizro_light"); +test("true returns vizro_light and false vizro_dark", () => { + expect(_update_dashboard_theme(true)).toBe("vizro_light"); + expect(_update_dashboard_theme(false)).toBe("vizro_dark"); }); diff --git a/vizro-core/tests/unit/vizro/actions/test_filter_action.py b/vizro-core/tests/unit/vizro/actions/test_filter_action.py index 3e4cb3217..4c2b68a56 100644 --- a/vizro-core/tests/unit/vizro/actions/test_filter_action.py +++ b/vizro-core/tests/unit/vizro/actions/test_filter_action.py @@ -50,7 +50,7 @@ def callback_context_filter_continent(request): "theme_selector": CallbackTriggerDict( id="theme_selector", property="checked", - value=True, + value=False, str_id="theme_selector", triggered=False, ), @@ -89,7 +89,7 @@ def callback_context_filter_continent_and_pop(request): "theme_selector": CallbackTriggerDict( id="theme_selector", property="checked", - value=True, + value=False, str_id="theme_selector", triggered=False, ), diff --git a/vizro-core/tests/unit/vizro/actions/test_on_page_load_action.py b/vizro-core/tests/unit/vizro/actions/test_on_page_load_action.py index 2de953dd0..2cbb52bab 100644 --- a/vizro-core/tests/unit/vizro/actions/test_on_page_load_action.py +++ b/vizro-core/tests/unit/vizro/actions/test_on_page_load_action.py @@ -81,7 +81,7 @@ def callback_context_on_page_load(request): "theme_selector": CallbackTriggerDict( id="theme_selector", property="checked", - value=template == "vizro_dark", + value=template == "vizro_light", str_id="theme_selector", triggered=False, ), diff --git a/vizro-core/tests/unit/vizro/actions/test_parameter_action.py b/vizro-core/tests/unit/vizro/actions/test_parameter_action.py index a098f99aa..73d74c933 100644 --- a/vizro-core/tests/unit/vizro/actions/test_parameter_action.py +++ b/vizro-core/tests/unit/vizro/actions/test_parameter_action.py @@ -69,7 +69,7 @@ def callback_context_parameter_y(request): "theme_selector": CallbackTriggerDict( id="theme_selector", property="checked", - value=True, + value=False, str_id="theme_selector", triggered=False, ), @@ -101,7 +101,7 @@ def callback_context_parameter_hover_data(request): "theme_selector": CallbackTriggerDict( id="theme_selector", property="checked", - value=True, + value=False, str_id="theme_selector", triggered=False, ), @@ -140,7 +140,7 @@ def callback_context_parameter_y_and_x(request): "theme_selector": CallbackTriggerDict( id="theme_selector", property="checked", - value=True, + value=False, str_id="theme_selector", triggered=False, ), diff --git a/vizro-core/tests/unit/vizro/models/_components/test_graph.py b/vizro-core/tests/unit/vizro/models/_components/test_graph.py index 17b1434b5..feae19b10 100644 --- a/vizro-core/tests/unit/vizro/models/_components/test_graph.py +++ b/vizro-core/tests/unit/vizro/models/_components/test_graph.py @@ -116,7 +116,7 @@ def test_update_theme_inside_callback(self, standard_px_chart, template): "theme_selector": CallbackTriggerDict( id="theme_selector", property="checked", - value=template == "vizro_dark", + value=template == "vizro_light", str_id="theme_selector", triggered=False, ) From b1057c3c50be460088125eee020fcce69deb769a Mon Sep 17 00:00:00 2001 From: huong-li-nguyen Date: Wed, 3 Jan 2024 17:05:45 +0100 Subject: [PATCH 5/9] Add changelog --- ...g_li_nguyen_replace_selected_components.md | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 vizro-core/changelog.d/20240103_170310_huong_li_nguyen_replace_selected_components.md diff --git a/vizro-core/changelog.d/20240103_170310_huong_li_nguyen_replace_selected_components.md b/vizro-core/changelog.d/20240103_170310_huong_li_nguyen_replace_selected_components.md new file mode 100644 index 000000000..e3b7f99c1 --- /dev/null +++ b/vizro-core/changelog.d/20240103_170310_huong_li_nguyen_replace_selected_components.md @@ -0,0 +1,48 @@ + + + + + + + + +### Fixed + +- Add CSS for `dmc.Switch` and fix CSS when toggle-switch is turned on ([#244](https://github.com/mckinsey/vizro/pull/244)) + + + From 99b632f84dff2bd4c0e79715a37bee4e9e16b233 Mon Sep 17 00:00:00 2001 From: huong-li-nguyen Date: Wed, 3 Jan 2024 17:08:40 +0100 Subject: [PATCH 6/9] Lint --- ...0240103_170310_huong_li_nguyen_replace_selected_components.md | 1 - 1 file changed, 1 deletion(-) diff --git a/vizro-core/changelog.d/20240103_170310_huong_li_nguyen_replace_selected_components.md b/vizro-core/changelog.d/20240103_170310_huong_li_nguyen_replace_selected_components.md index e3b7f99c1..d6813a9b2 100644 --- a/vizro-core/changelog.d/20240103_170310_huong_li_nguyen_replace_selected_components.md +++ b/vizro-core/changelog.d/20240103_170310_huong_li_nguyen_replace_selected_components.md @@ -39,7 +39,6 @@ Uncomment the section that is right (remove the HTML comment wrapper). - Add CSS for `dmc.Switch` and fix CSS when toggle-switch is turned on ([#244](https://github.com/mckinsey/vizro/pull/244)) -