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: 5ea1b171969bd0f9185d243aae5a8bf0934a275c537ea19945bb9e386bbd177e
4
- data.tar.gz: ee66e7f2d9d3ba8a3d0c2308d13349cf87e98cd43e336ced4d74f3b63a0fd8da
3
+ metadata.gz: eab13e7d1cafe4555104a7564d58aa13d10022ae804c556dd122003aa39902ba
4
+ data.tar.gz: 0c2180f0be12b471f6833fc4654284332e5fc8d571e6cdde0f07900654a122e4
5
5
  SHA512:
6
- metadata.gz: a14b2849acc3cb33b56bc6e64821b92aced673a2543d91bf419fc4cf42c676bc2f5f75da94c2aa85f38183e1afd72116ce0b1585a6aecfa61b7b12ab6306d708
7
- data.tar.gz: 64802fe9552bafa4d4c23a5e4e2b47f5249d294b55bf2e82914596d2e33a920fd6a074d4d5fdef3cf68103ddc9235a4fd2a415c559e3ab11b320d54d34796608
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
  }
@@ -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
- - **Turbo morph page refreshes.** Reconciliation on failure uses a Turbo refresh, which must morph (not hard reload) to be seamless. The generator adds these to your layout `<head>`:
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:
@@ -1,5 +1,5 @@
1
1
  module HotwireClub
2
2
  module Toolbox
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hotwire_club-toolbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Rubisch