Skip to content

Commit

Permalink
Don't propose visit if the location is the same as the current visit
Browse files Browse the repository at this point in the history
This solves some blinking when there's a redirection to the current page.
  • Loading branch information
afcapel committed Nov 15, 2023
1 parent c476bac commit 7d94f59
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Source/WebView/turbo.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
}
}
}

clearSnapshotCache() {
if (window.Turbo) {
Turbo.session.clearCache()
Expand Down Expand Up @@ -103,6 +103,9 @@
if (Turbo.navigator.locationWithActionIsSamePage(location, options.action)) {
Turbo.navigator.view.scrollToAnchorFromLocation(location)
return
} else if (this.currentVisit?.location?.href === location.href) {
this.visitLocationWithOptionsAndRestorationIdentifier(location, options, Turbo.navigator.restorationIdentifier)
return
}
}

Expand Down Expand Up @@ -146,7 +149,7 @@
visitCompleted(visit) {
this.postMessage("visitCompleted", { identifier: visit.identifier, restorationIdentifier: visit.restorationIdentifier })
}

formSubmissionStarted(formSubmission) {
this.postMessage("formSubmissionStarted", { location: formSubmission.location.toString() })
}
Expand Down

0 comments on commit 7d94f59

Please sign in to comment.