allow customizing the restore condition - #20
Merged
Conversation
manuelpuyol
marked this pull request as ready for review
March 14, 2025 21:22
There was a problem hiding this comment.
Pull Request Overview
This PR updates the framework to allow consumers to customize the restore condition and to transmit an action value when rendering snapshots.
- Updates History to include a customizable shouldRestore function and modifies the popstate check to utilize it.
- Updates TurboBeforeRenderEvent type and adjusts render methods signatures and calls across View and PageView to pass an optional action parameter.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/core/drive/history.ts | Adds a customizable shouldRestore function and updates popstate handling. |
| src/core/session.ts | Updates TurboBeforeRenderEvent to include an optional action property. |
| src/core/view.ts | Modifies render method signature to accept and propagate an optional action. |
| src/core/drive/page_view.ts | Updates render and renderError to pass the action parameter from visit. |
Comments suppressed due to low confidence (2)
src/core/drive/history.ts:25
- The new customizable 'shouldRestore' function is introduced without direct test coverage; add tests to verify its behavior.
shouldRestore: (state: any) => boolean = () => true
src/core/view.ts:94
- The new 'action' property passed in the render options should be covered by tests to ensure correct propagation.
const options = { resume: this.resolveInterceptionPromise, render: this.renderer.renderElement, action }
Tip: Copilot only keeps its highest confidence comments to reduce noise and keep you focused. Learn more
Collaborator
Author
|
idk why tests are not running, but I'm also not really worried about that with this PR... |
manuelpuyol
force-pushed
the
mp/custom-restore
branch
from
March 14, 2025 21:25
1c9a836 to
6f28385
Compare
gracepark
approved these changes
Mar 14, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This enabled the consumer to setup a custom
shouldRestorefunction to decide whether turbo should manage the b/f navigation