-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix: ensure beforeNavigate
works on other navigations after clicking a download link
#9747
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
Open
eltigerchino
wants to merge
34
commits into
main
Choose a base branch
from
fix-implicit-download-before-navigate
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
6bcfec8
add test
eltigerchino d6d8a1f
fix test
eltigerchino be5b1dc
only call before_navigate if external link is unloading page
eltigerchino 42c683a
rename external_link flag
eltigerchino 0fb55dc
changeset
eltigerchino e1a861e
format
eltigerchino 0c892ed
Merge branch 'master' into fix-implicit-download-before-navigate
eltigerchino 91cfd72
revert changes and update tests
eltigerchino 4beaab5
comment
eltigerchino 32e68ca
oopsie accidentally removed this
eltigerchino 98d2caa
forgot to revert this too
eltigerchino 33ad7f6
fix test
eltigerchino ed3d004
add fix
eltigerchino 0eedd67
maybe this will fix the ubuntu tests?
eltigerchino 4f16369
Revert "maybe this will fix the ubuntu tests?"
eltigerchino d69fcda
Merge branch 'master' into fix-implicit-download-before-navigate
eltigerchino dc283bb
Merge branch 'master' into fix-implicit-download-before-navigate
eltigerchino dc7f1b0
Merge branch 'main' into fix-implicit-download-before-navigate
eltigerchino 8e46929
fix merge differences
eltigerchino ea529ba
try this?
eltigerchino b97cba1
use locator
eltigerchino 82c04c7
try this nonsense
eltigerchino 267840a
fix test names
eltigerchino 8d01c5d
remove unused link
eltigerchino 6d8cf4c
fix flaky tests?
eltigerchino 76af069
fix native navigations that download a file
eltigerchino 8ff1e86
wait for download to finish
eltigerchino 4ce3f24
apparently other tests wait for networkidle so this should be fine
eltigerchino 645ceb1
prettier
eltigerchino 0b48eab
remove throwing error if downloads
eltigerchino f89f269
cancel download because it interferes with navigation
eltigerchino c83dfab
need to wait for event first probably?
eltigerchino a5c0efd
Merge branch 'main' into fix-implicit-download-before-navigate
benmccann a9c1801
Merge branch 'main' into fix-implicit-download-before-navigate
eltigerchino File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sveltejs/kit': patch | ||
--- | ||
|
||
fix: ensure `beforeNavigate` works on other navigations after clicking a download link |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
.../kit/test/apps/basics/src/routes/navigation-lifecycle/before-navigate/download/+server.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export function GET() { | ||
return new Response('ok', { | ||
headers: { | ||
'Content-Disposition': 'attachment' | ||
} | ||
}); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this has me a bit uneasy. Are there any situations where this can be true but it is not a download?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only if
native_navigation
is being used to navigate to the same page. However, it's currently only used as a fallback when navigating to another page. e.g., clicking a link that has a different href than the current pageThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, what if for some reason the response redirected you back to where you came from?
Are we unable to detect that something is a download before starting a navigation that really isn't one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's tricky. Some downloads are only detectable once the response headers have been downloaded and
Content-Disposition: attachment
is present. Another option is to revert this and let the developer be explicit about which links are downloads with thedownload
attribute so they don't run into this issue.