Skip to content

Commit

Permalink
Build with latest turbo/main
Browse files Browse the repository at this point in the history
  • Loading branch information
afcapel committed Nov 20, 2023
1 parent b385276 commit 1d6b6d3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
22 changes: 15 additions & 7 deletions app/assets/javascripts/turbo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2231,15 +2231,18 @@ class BrowserAdapter {
return visit.loadResponse();
}
}
visitRequestFinished(_visit) {
visitRequestFinished(_visit) {}
visitCompleted(_visit) {
this.progressBar.setValue(1);
this.hideVisitProgressBar();
}
visitCompleted(_visit) {}
pageInvalidated(reason) {
this.reload(reason);
}
visitFailed(_visit) {}
visitFailed(_visit) {
this.progressBar.setValue(1);
this.hideVisitProgressBar();
}
visitRendered(_visit) {}
formSubmissionStarted(_formSubmission) {
this.progressBar.setValue(0);
Expand Down Expand Up @@ -2521,7 +2524,7 @@ class Navigator {
this.view.clearSnapshotCache();
}
const {statusCode: statusCode, redirected: redirected} = fetchResponse;
const action = this.getActionForFormSubmission(formSubmission);
const action = this.#getActionForFormSubmission(formSubmission, fetchResponse);
const visitOptions = {
action: action,
shouldCacheSnapshot: shouldCacheSnapshot,
Expand Down Expand Up @@ -2579,8 +2582,13 @@ class Navigator {
get restorationIdentifier() {
return this.history.restorationIdentifier;
}
getActionForFormSubmission({submitter: submitter, formElement: formElement}) {
return getVisitAction(submitter, formElement) || "advance";
#getActionForFormSubmission(formSubmission, fetchResponse) {
const {submitter: submitter, formElement: formElement} = formSubmission;
return getVisitAction(submitter, formElement) || this.#getDefaultAction(fetchResponse);
}
#getDefaultAction(fetchResponse) {
const sameLocationRedirect = fetchResponse.redirected && fetchResponse.location.href === this.location?.href;
return sameLocationRedirect ? "replace" : "advance";
}
}

Expand Down Expand Up @@ -3655,7 +3663,7 @@ class PageView extends View {
return this.snapshotCache.get(location);
}
isPageRefresh(visit) {
return !visit || this.lastRenderedLocation.href === visit.location.href;
return !visit || this.lastRenderedLocation.href === visit.location.href && visit.action === "replace";
}
get snapshot() {
return PageSnapshot.fromElement(this.element);
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/turbo.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/assets/javascripts/turbo.min.js.map

Large diffs are not rendered by default.

0 comments on commit 1d6b6d3

Please sign in to comment.