mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
Missing "onClick" prop in @verdaccio/ui-components Link component preventing handleDownload call in Package.tsx #3988 (#3989)
* fix: Add onClick handler in Link component In the "Link" component, the onClick handler was not provided, leading to the absence of a download action in the Package.tsx renderDownloadLink component. * Removed "external" attribute from "renderDownloadLink" The "external" attribute is unnecessary in this context since the download action is triggered by the "handleDownload" callback. * added changeset for @verdaccio/ui-components
This commit is contained in:
parent
bdfdf711e5
commit
e056c8dfd3
3 changed files with 16 additions and 4 deletions
6
.changeset/chilled-carrots-guess.md
Normal file
6
.changeset/chilled-carrots-guess.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
'@verdaccio/ui-components': patch
|
||||
---
|
||||
|
||||
- added `onClick` prop to `Link` component in @verdaccio/ui-components. (@moglerdev in #3989)
|
||||
- resolved issue in the `Package` component where the download button was incorrectly opening a new tab to the homepage. (@moglerdev in #3989)
|
|
@ -15,15 +15,22 @@ export const CustomRouterLink = styled(RouterLink)`
|
|||
|
||||
// TODO: improve any with custom types for a and RouterLink
|
||||
const Link = React.forwardRef<LinkRef, any>(function LinkFunction(
|
||||
{ external, to, children, variant, className },
|
||||
{ external, to, children, variant, className, onClick },
|
||||
ref
|
||||
) {
|
||||
return external ? (
|
||||
<a className={className} href={to} ref={ref} rel="noopener noreferrer" target="_blank">
|
||||
<a
|
||||
className={className}
|
||||
href={to}
|
||||
onClick={onClick}
|
||||
ref={ref}
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
<Typography variant={variant ?? 'caption'}>{children}</Typography>
|
||||
</a>
|
||||
) : (
|
||||
<CustomRouterLink className={className} innerRef={ref} to={to}>
|
||||
<CustomRouterLink className={className} innerRef={ref} onClick={onClick} to={to}>
|
||||
<Typography variant={variant}>{children}</Typography>
|
||||
</CustomRouterLink>
|
||||
);
|
||||
|
|
|
@ -163,7 +163,6 @@ const Package: React.FC<PackageInterface> = ({
|
|||
dist?.tarball &&
|
||||
url.isURL(dist.tarball) && (
|
||||
<Link
|
||||
external={true}
|
||||
onClick={() => {
|
||||
handleDownload(dist.tarball);
|
||||
}}
|
||||
|
|
Loading…
Reference in a new issue