Skip to content

Commit

Permalink
Support opening logo url in same tab
Browse files Browse the repository at this point in the history
REDMINE-20930
  • Loading branch information
tf committed Jan 28, 2025
1 parent 7c12cc3 commit 5617769
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,32 @@ describe('DefaultNavigation', () => {

expect(getByRole('link', {name: 'My logo'})).toBeInTheDocument();
expect(getByRole('link', {name: 'My logo'})).toHaveAttribute('href', 'https://example.com');
expect(getByRole('link', {name: 'My logo'})).toHaveAttribute('target', '_blank');
expect(getByRole('img', {name: 'My logo'})).toHaveAttribute('src', 'logo-desktop.png');
});

it('supports opening logo link in same tab', () => {
const {getByRole} = renderInEntry(
<DefaultNavigation configuration={{}} />,
{
seed: {
themeAssets: {
logoDesktop: 'logo-desktop.png'
},
themeOptions: {
logoUrl: 'https://example.com',
logoAltText: 'My logo',
logoOpenInSameTab: true
}
}
}
);

expect(getByRole('link', {name: 'My logo'})).toBeInTheDocument();
expect(getByRole('link', {name: 'My logo'})).toHaveAttribute('href', 'https://example.com');
expect(getByRole('link', {name: 'My logo'})).not.toHaveAttribute('target');
});

it('takes logo props', () => {
const {getByRole} = renderInEntry(
<DefaultNavigation configuration={{}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function Logo({srcMobile, srcDesktop, url, altText}) {
(darkWidgets ? theme.assets.logoDarkVariantMobile : theme.assets.logoMobile);

return (
<a target="_blank"
<a target={theme.options.logoOpenInSameTab ? null : "_blank"}
rel="noopener noreferrer"
href={url || theme.options.logoUrl}
className={classNames(
Expand Down

0 comments on commit 5617769

Please sign in to comment.