Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable PDFDownloadLink to Receive Anchor Props #2071

Merged
merged 4 commits into from
Jan 14, 2024

Conversation

ITenthusiasm
Copy link
Contributor

Motivation

There are a few reasons why someone might want to leverage all of the attributes available on the related anchor (a) element for PDFDownloadLink. This PR makes this possible without ruining backwards compatibility (download is now legal; fileName is still preserved; and fileName will yield to download if the attribute is explicitly added). The TS props were also updated for clarity.

It might be useful to have this on the v2 and v3 versions? Since it seems like some people in the react@18 world are having a hard time? But I leave that to you guys.

I considered adding React.forwardRef too, but I didn't want to dive through additional TS headaches. Might be worth considering later?

Changes

  • Pass ALL anchor tag props to the rendered anchor element -- EXCLUDING the reserved href attribute.
  • Improve the onClick type of PDFDownloadLink.
  • Minor cleanup in related files.

Changes:
- Pass ALL anchor tag props to the rendered anchor
  element -- EXCLUDING the reserved `href` attribute.
- Improve the `onClick` type of `PDFDownloadLink`.
- Minor cleanup in related files.
packages/renderer/src/dom/PDFDownloadLink.js Outdated Show resolved Hide resolved
packages/renderer/src/dom/PDFDownloadLink.js Outdated Show resolved Hide resolved
packages/renderer/src/dom/PDFDownloadLink.js Outdated Show resolved Hide resolved
@diegomura diegomura changed the title feat: Enable PDFDownloadLink to Receive Anchor Props feat: enable PDFDownloadLink to Receive Anchor Props Jan 14, 2024
Copy link

changeset-bot bot commented Jan 14, 2024

⚠️ No Changeset found

Latest commit: b1291e5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Owner

@diegomura diegomura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@diegomura diegomura merged commit 8b00577 into diegomura:master Jan 14, 2024
1 check passed
mskec pushed a commit to mskec/react-pdf that referenced this pull request Feb 26, 2024
* feat: Enable `PDFDownloadLink` to Receive Anchor Props

Changes:
- Pass ALL anchor tag props to the rendered anchor
  element -- EXCLUDING the reserved `href` attribute.
- Improve the `onClick` type of `PDFDownloadLink`.
- Minor cleanup in related files.

* feat: preserve doc var

* fix: preserve blank line

---------

Co-authored-by: Diego Muracciole <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants