Fix issue where radar entry dialog with external url
If an entry has both a radar description and an external url, when a user clicks on the blip the description dialog would briefly appear before they are redirected to the specified url. Expected behaviour is not to automatically redirect the user so that they can read the dialog and choose to follow the link for more details. Signed-off-by: Niall McCullagh <mccullagh_niall@hotmail.com> Signed-off-by: Niall McCullagh <niallmccullagh@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-tech-radar': patch
|
||||
---
|
||||
|
||||
Fixes issue where radar description dialog is not shown when the entry has an url external to the radar page
|
||||
@@ -79,4 +79,20 @@ describe('RadarEntry', () => {
|
||||
expect(radarDescription).toBeInTheDocument();
|
||||
expect(screen.getByText(String(minProps.value))).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render blip with url equal to # if description present', () => {
|
||||
const withUrl = {
|
||||
...optionalProps,
|
||||
url: 'http://backstage.io',
|
||||
};
|
||||
render(
|
||||
<ThemeProvider theme={lightTheme}>
|
||||
<svg>
|
||||
<RadarEntry {...withUrl} />
|
||||
</svg>
|
||||
</ThemeProvider>,
|
||||
);
|
||||
|
||||
expect(screen.getByRole('button')).toHaveAttribute('href', '#');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -111,11 +111,12 @@ const RadarEntry = (props: Props): JSX.Element => {
|
||||
/>
|
||||
)}
|
||||
{description ? (
|
||||
// eslint-disable-next-line jsx-a11y/anchor-is-valid
|
||||
<a
|
||||
className={classes.link}
|
||||
onClick={handleClickOpen}
|
||||
href={url ? url : '#'}
|
||||
role="button"
|
||||
href="#"
|
||||
tabIndex={0}
|
||||
onKeyPress={toggle}
|
||||
>
|
||||
|
||||
@@ -72,9 +72,11 @@ entries.push({
|
||||
moved: 1,
|
||||
ringId: 'use',
|
||||
date: new Date('2020-08-06'),
|
||||
description:
|
||||
'Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur',
|
||||
},
|
||||
],
|
||||
url: '#',
|
||||
url: 'https://webpack.js.org/',
|
||||
key: 'webpack',
|
||||
id: 'webpack',
|
||||
title: 'Webpack',
|
||||
|
||||
Reference in New Issue
Block a user