diff --git a/vizro-core/changelog.d/20240716_091858_maximilian_schulz_try_out_link_target.md b/vizro-core/changelog.d/20240716_091858_maximilian_schulz_try_out_link_target.md new file mode 100644 index 000000000..e5c49cb41 --- /dev/null +++ b/vizro-core/changelog.d/20240716_091858_maximilian_schulz_try_out_link_target.md @@ -0,0 +1,47 @@ + + + + + + + + +### Fixed + +- External `href` links in `vm.Card` now open in the full body of the window as opposed to in the same frame as they were clicked. ([#585](https://github.com/mckinsey/vizro/pull/585)) + + diff --git a/vizro-core/src/vizro/models/_components/card.py b/vizro-core/src/vizro/models/_components/card.py index fc2f93fe8..2638b63ac 100644 --- a/vizro-core/src/vizro/models/_components/card.py +++ b/vizro-core/src/vizro/models/_components/card.py @@ -39,6 +39,7 @@ def build(self): dbc.NavLink( children=text, href=get_relative_path(self.href) if self.href.startswith("/") else self.href, + target="_top", ) if self.href else text diff --git a/vizro-core/tests/unit/vizro/models/_components/test_card.py b/vizro-core/tests/unit/vizro/models/_components/test_card.py index c2fe1fa09..44c9d24ab 100755 --- a/vizro-core/tests/unit/vizro/models/_components/test_card.py +++ b/vizro-core/tests/unit/vizro/models/_components/test_card.py @@ -53,6 +53,7 @@ def test_card_build_with_href(self): dbc.NavLink( dcc.Markdown(id="card_id", children="Hello", dangerously_allow_html=False), href="https://www.google.com", + target="_top", ), className="card-nav", )