hotwire_club-toolbox 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eab13e7d1cafe4555104a7564d58aa13d10022ae804c556dd122003aa39902ba
|
|
4
|
+
data.tar.gz: 0c2180f0be12b471f6833fc4654284332e5fc8d571e6cdde0f07900654a122e4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 90fbb870a4451098ddafc9555698430820a2078cc0e453e04978cec81ce80affc21b8323bef84fc0b3a2b8cc54e56d765034c746c4347c85acf16f73563cced7
|
|
7
|
+
data.tar.gz: 1740ae1b6c65fae06179e612032bf02656429b43f95414f351e15c87846af0785475e143dcb9f93eb803b3a2944d61929efa55ec9fb374ec84c465fa9149c5ac
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented here.
|
|
4
4
|
|
|
5
|
+
## [0.2.2]
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
- **Optimistic Form**: the failure refresh asks for a morph itself
|
|
9
|
+
(`<turbo-stream action="refresh" method="morph" scroll="preserve">`), so
|
|
10
|
+
with Turbo 8.0.21 or later the app no longer needs the
|
|
11
|
+
`turbo-refresh-method`/`-scroll` meta tags, which also change every other
|
|
12
|
+
page refresh in the app. Older Turbo ignores the attributes and still reads
|
|
13
|
+
the meta tags. Apps that copied `optimistic_form_controller.js` (jsbundling,
|
|
14
|
+
vite) need to copy it again to get this.
|
|
15
|
+
|
|
5
16
|
## [0.2.1]
|
|
6
17
|
|
|
7
18
|
### Fixed
|
|
@@ -59,9 +59,12 @@ export default class extends Controller {
|
|
|
59
59
|
this.reconciled.add(formSubmission);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
// Morph for this refresh alone, so the app's other page refreshes keep their
|
|
63
|
+
// own render. Turbo before 8.0.21 ignores the attributes and falls back to
|
|
64
|
+
// the turbo-refresh-method/-scroll meta tags.
|
|
62
65
|
document.body.insertAdjacentHTML(
|
|
63
66
|
"beforeend",
|
|
64
|
-
'<turbo-stream action="refresh"></turbo-stream>',
|
|
67
|
+
'<turbo-stream action="refresh" method="morph" scroll="preserve"></turbo-stream>',
|
|
65
68
|
);
|
|
66
69
|
}
|
|
67
70
|
}
|
data/docs/optimistic-form.md
CHANGED
|
@@ -22,13 +22,17 @@ It also ensures the Turbo morph refresh meta tags (see Prerequisites) are presen
|
|
|
22
22
|
### Prerequisites
|
|
23
23
|
|
|
24
24
|
- **Turbo and Stimulus** in the host app.
|
|
25
|
-
- **
|
|
25
|
+
- **A morphing refresh.** Reconciliation on failure uses a Turbo page refresh, which must morph (not replace the page) to be seamless. The controller asks for that on its own refresh, `<turbo-stream action="refresh" method="morph" scroll="preserve">`, so with **Turbo 8.0.21 or later** (turbo-rails 2.0.21 or later) nothing else is needed, and the app's other page refreshes keep rendering the way they do.
|
|
26
|
+
|
|
27
|
+
Older Turbo ignores those attributes and takes the method from the page instead. There, add these to your layout `<head>` (the generator does):
|
|
26
28
|
|
|
27
29
|
```html
|
|
28
30
|
<meta name="turbo-refresh-method" content="morph">
|
|
29
31
|
<meta name="turbo-refresh-scroll" content="preserve">
|
|
30
32
|
```
|
|
31
33
|
|
|
34
|
+
They apply to every page refresh in the app, not only the toolbox's: a Back-button `Turbo.visit(location, {action: "replace"})`, or a top-level form that redirects to the page it was posted from, morphs too.
|
|
35
|
+
|
|
32
36
|
## Basic usage
|
|
33
37
|
|
|
34
38
|
A favorite toggle. The `optimistic_template` predicts the toggled state; the button shows the current one:
|