mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-02-21 07:29:37 +01: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
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
|
// TODO: improve any with custom types for a and RouterLink
|
||||||
const Link = React.forwardRef<LinkRef, any>(function LinkFunction(
|
const Link = React.forwardRef<LinkRef, any>(function LinkFunction(
|
||||||
{ external, to, children, variant, className },
|
{ external, to, children, variant, className, onClick },
|
||||||
ref
|
ref
|
||||||
) {
|
) {
|
||||||
return external ? (
|
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>
|
<Typography variant={variant ?? 'caption'}>{children}</Typography>
|
||||||
</a>
|
</a>
|
||||||
) : (
|
) : (
|
||||||
<CustomRouterLink className={className} innerRef={ref} to={to}>
|
<CustomRouterLink className={className} innerRef={ref} onClick={onClick} to={to}>
|
||||||
<Typography variant={variant}>{children}</Typography>
|
<Typography variant={variant}>{children}</Typography>
|
||||||
</CustomRouterLink>
|
</CustomRouterLink>
|
||||||
);
|
);
|
||||||
|
@ -163,7 +163,6 @@ const Package: React.FC<PackageInterface> = ({
|
|||||||
dist?.tarball &&
|
dist?.tarball &&
|
||||||
url.isURL(dist.tarball) && (
|
url.isURL(dist.tarball) && (
|
||||||
<Link
|
<Link
|
||||||
external={true}
|
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
handleDownload(dist.tarball);
|
handleDownload(dist.tarball);
|
||||||
}}
|
}}
|
||||||
|
Loading…
Reference in New Issue
Block a user