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

PDF attachment not rendering right when ViewTransition is enabled. #7947

Closed
1 task
chenxsan opened this issue Aug 4, 2023 · 11 comments · Fixed by #8153
Closed
1 task

PDF attachment not rendering right when ViewTransition is enabled. #7947

chenxsan opened this issue Aug 4, 2023 · 11 comments · Fixed by #8153
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) feat: view transitions Related to the View Transitions feature (scope)

Comments

@chenxsan
Copy link
Contributor

chenxsan commented Aug 4, 2023

What version of astro are you using?

2.10.1

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

pnpm

What operating system are you using?

Mac

What browser are you using?

Chrome

Describe the Bug

Say I have a pdf file containing Chinese texts under public folder, and I have a link to that pdf file in one of my pages:

<a href="/chinese.pdf">A PDF containing Chinese.</a>

With ViewTransition enabled, clicking that link would return something like this:
CleanShot-a46EcksI@2x

What's the expected result?

I would expect the browser to show the pdf content.

Link to Minimal Reproducible Example

https://github.com/chenxsan/astro-view-transition-pdf

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Aug 4, 2023
@matthewp
Copy link
Contributor

matthewp commented Aug 4, 2023

Could you add the download attribute here? We could support that as a way to signal the router not to treat it as page navigation.

We might also want a data-astro-no-follow (bikeshed) or something so you can prevent router navigation. cc @natemoo-re for ideas.

@matthewp matthewp added feat: view transitions Related to the View Transitions feature (scope) - P3: minor bug An edge case that only affects very specific usage (priority) and removed needs triage Issue needs to be triaged labels Aug 4, 2023
@chenxsan
Copy link
Contributor Author

chenxsan commented Aug 4, 2023

Could you add the download attribute here? We could support that as a way to signal the router not to treat it as page navigation.

We might also want a data-astro-no-follow (bikeshed) or something so you can prevent router navigation. cc @natemoo-re for ideas.

but I don't want to download it, I just want to view the file in browser. Fyi, it's not just pdf file, all images would show the similar result:

CleanShot-Zi8sJ6N1@2x

@natemoo-re
Copy link
Member

We might also want a data-astro-no-follow (bikeshed) or something so you can prevent router navigation. cc @natemoo-re for ideas.

data-astro-reload or rel="nofollow" would work. SvelteKit supports the former.

@chenxsan
Copy link
Contributor Author

chenxsan commented Aug 7, 2023

We might also want a data-astro-no-follow (bikeshed) or something so you can prevent router navigation. cc @natemoo-re for ideas.

data-astro-reload or rel="nofollow" would work. SvelteKit supports the former.

Users don't have to add the attribute manually right? The compiler would handle them automatically?

@matthewp
Copy link
Contributor

Yeah users would need to add it. By default we have to assume that same-site navigation is to another page and not to a file.

@martrapp
Copy link
Member

martrapp commented Aug 18, 2023

I will go with data-astro-reload, which is close to the names of this feature in other client-side routers like react router or the sveltekit router.

@matthewp
Copy link
Contributor

@martrapp can you link to docs on those other routers?

@martrapp
Copy link
Member

Do we need a mapping in the compiler for this? (e.g. transition:reload)?

@martrapp
Copy link
Member

@chenxsan I changed the link in your example to

	<a href="/chinese.pdf" data-astro-reload>A PDF containing Chinese.</a>

with the new Astro version (not yet released) the PDF is shows in the browser when the user clicks the link.
image

@matthewp
Copy link
Contributor

Fixed by #8217. Will do a new RC tomorrow with these changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) feat: view transitions Related to the View Transitions feature (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants