0
Fork 0
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:
Christopher Jäger (Mogler) 2023-08-24 21:52:35 +02:00 committed by GitHub
parent bdfdf711e5
commit e056c8dfd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 4 deletions

View 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)

View file

@ -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>
);

View file

@ -163,7 +163,6 @@ const Package: React.FC<PackageInterface> = ({
dist?.tarball &&
url.isURL(dist.tarball) && (
<Link
external={true}
onClick={() => {
handleDownload(dist.tarball);
}}