-
Notifications
You must be signed in to change notification settings - Fork 432
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
Only update history when Turbo visit is renderable #601
Changes from all commits
6dcf1eb
f6456da
b3c08c3
ed11325
fe0d60e
6b726a5
3dc8ac7
2eb9ea2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ export class BrowserAdapter implements Adapter { | |
|
||
visitProgressBarTimeout?: number | ||
formProgressBarTimeout?: number | ||
location?: URL | ||
|
||
constructor(session: Session) { | ||
this.session = session | ||
|
@@ -27,9 +28,9 @@ export class BrowserAdapter implements Adapter { | |
} | ||
|
||
visitStarted(visit: Visit) { | ||
this.location = visit.location | ||
visit.loadCachedSnapshot() | ||
visit.issueRequest() | ||
visit.changeHistory() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not positive, but moving the history changing to
The second should be a no-op because history will have been flagged as changed, but I think we'll still have the same problem. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how do we avoid calling it twice now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's only called once by each adapter now. If we move it out of the browser adapter, we may need to move it out of the other adapters as well. Perhaps we don't (it's been a while since I've looked at the native frameworks), but we need to make sure it behaves as expected on iOS and Android. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any tips on how to test that properly? Looking at https://github.com/manuelpuyol/turbo/blob/2eb9ea2c7282f1ec2b41c75705d7e43af7e2076a/src/core/drive/visit.ts#L173-L174 I'd expect it to not do a double update There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, it will be a no-op because we've already flagged history as having changed. My concern is that we're changing the behavior by moving this out of the adapter, so we just need to ensure it's all good on iOS and Android 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jayohms Can you verify whether this would bring any complication on native? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't foresee any issues on the mobile side, since as mentioned, the second I don't think we'll be able to reasonably make corresponding changes in the mobile adapters without exposing an additional API, so the adapters can know to conditionally change history (or not). This shouldn't be a problem in the short-term, but it may be a nuance that's difficult for others to understand as time goes on. |
||
visit.goToSamePageAnchor() | ||
} | ||
|
||
|
@@ -121,7 +122,10 @@ export class BrowserAdapter implements Adapter { | |
|
||
reload(reason: ReloadReason) { | ||
dispatch("turbo:reload", { detail: reason }) | ||
window.location.reload() | ||
|
||
if (!this.location) return | ||
|
||
window.location.href = this.location.toString() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any potential that this causes issues with or prevents reloads for same-page anchors? I'm not clear if that situation is possible here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't imagine a case where a same-page anchor causes a full page reload |
||
} | ||
|
||
get navigator() { | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -6,8 +6,17 @@ | |||||||||||||||||||||
<script src="/dist/turbo.es2017-umd.js" data-turbo-track="reload"></script> | ||||||||||||||||||||||
<script src="/src/tests/fixtures/test.js"></script> | ||||||||||||||||||||||
<meta name="turbo-visit-control" content="reload"> | ||||||||||||||||||||||
</head> | ||||||||||||||||||||||
<body> | ||||||||||||||||||||||
<h1>Visit control: reload</h1> | ||||||||||||||||||||||
<style> | ||||||||||||||||||||||
.push-off-screen { margin-top: 1000px; } | ||||||||||||||||||||||
</style> | ||||||||||||||||||||||
</head> | ||||||||||||||||||||||
<body> | ||||||||||||||||||||||
<h1>Visit control: reload</h1> | ||||||||||||||||||||||
|
||||||||||||||||||||||
<hr class="push-off-screen"> | ||||||||||||||||||||||
|
||||||||||||||||||||||
<h2 id="middle">Middle the page</h2> | ||||||||||||||||||||||
<hr class="push-off-screen"> | ||||||||||||||||||||||
<h2>Down the page</h2> | ||||||||||||||||||||||
Comment on lines
+16
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very nit-pick but:
Suggested change
|
||||||||||||||||||||||
</body> | ||||||||||||||||||||||
</html> |
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.
Probably in a follow-up refactor but it's starting to look like this function should take in a "options" object rather than individual arguments.