-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve Frame-to-Page Visit event ordering (#444)
* Resolve TypeScript build error Merging [9c74f77][] introduced a TypeScript build error, which is failing our CI build. This commit replaces the old `formSubmitted` helper with the newer `formSubmitEnded`. [9c74f77]: 9c74f77#diff-225e8f674fa1e4fd108c22a917fd5673e51909d4a5d8958e4874ae9e402dca2f * Extract SnapshotSubstitution from FrameController To refactor the `proposeVisitIfNavigatedWithAction()` implementation, this commit extracts the `SnapshotSubstitution` to manage replacing `Snapshot` references to `<turbo-frame>` elements whose visits are promoted to page-wide state. The class partially implement the `VisitDelegate` interface so that it can be passed directly as a `delegate:` option to the `session.visit()` call. * Resolve Frame-to-Page Visit event ordering The problem --- By attempting to avoid unnecessary renders and events by introducing the `willRender:` Visit option, the initial `<turbo-frame data-turbo-action="...">` implementation was skipping several crucial lifecycle hooks. For example, the resulting Visit would fire a `turbo:render`, but would not fire a `turbo:load`. This left the `<html>` element in an inconsistent state without cleaning up any `[data-turbo-preview]` or `[aria-busy]` attribute modifications. The solution --- Forego the `willRender:` option, and instead propose a visit with a pre-populated `statusCode`, `redirected`, and `responseHTML` value so that the `Session` (including all of its hooks) can handle transparently the same as other `Visit` instances. The result is much simpler than the original implementation: a promoted Visit doesn't receive any specialized treatment, so it stands to benefits from all the existing plumbing.
- Loading branch information
1 parent
9e0a9b4
commit 6b6bdb2
Showing
4 changed files
with
59 additions
and
28 deletions.
There are no files selected for viewing
This file contains 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 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 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 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