forked from hotwired/turbo
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
[method]
and [scroll]
attributes for Refresh Stream
> I have a page where I am using Turbo morph. when I submit a form and > redirect I would like to reset the scroll, but if a refresh is triggered > by a broadcast I would like to preserve teh scroll. Is that possible ? > > [#turbo Discord][discord] This commit expands the set of attributes for `<turbo-stream action="refresh">` to include `[method]` and `[scroll]` (in addition to `[request-id]`). These attributes correspond directly to the [`turbo-refresh`-prefixed `<meta>` element][meta] elements that control morphing and scroll preservation. When present on the `<turbo-stream action="refresh">`, their values are forward along to the `Session.refresh` method call, which in turn encodes them into Visit options under the `refresh` key. Those options are then used during `Visit` instantiation, and transformed into `.refresh` properties. At render time, the `PageRenderer` attempts to read the refresh method and scroll preservation settings with the following precedence: 1. read from the corresponding `Visit.refresh` property (possibly null) 2. read from the corresponding `<meta name="turbo-...">` element (possibly null) If no value is provided, fallback to the default (`{ method: "replace", scroll: "reset" }`). [discord]: https://discord.com/channels/988103760050012160/1044659721229054033/1212443786270212167 [meta]: https://turbo.hotwired.dev/handbook/page_refreshes#morphing
- Loading branch information
1 parent
00527e5
commit 56ffe7d
Showing
7 changed files
with
42 additions
and
12 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
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