hotwire_club-toolbox 0.2.0 → 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: 3ef4fb1e166b6dfb0c498a89f9dbdec29c95af1228d45d126a080ee4328ca44f
4
- data.tar.gz: 67c0d7880e2e4a9749632ebd5a59c84575046cf88589ca79e8ef0919062ce661
3
+ metadata.gz: eab13e7d1cafe4555104a7564d58aa13d10022ae804c556dd122003aa39902ba
4
+ data.tar.gz: 0c2180f0be12b471f6833fc4654284332e5fc8d571e6cdde0f07900654a122e4
5
5
  SHA512:
6
- metadata.gz: 9ace48512f23f6dd4fff86676542564f50354baa4e41520157bbca198ffedf01647798041ac1f6ed9cdd0b2b42933ae6a3cb20fd774a1153c3add0bd5cb00cfb
7
- data.tar.gz: 63c0130410564e5bee90f918521ab146caca70aeb266c5ba0e781a4e4e01290c149d1dc16f0e1ba5ef6029ec30a201ada01dff066418b73b7627f44956bc87bc
6
+ metadata.gz: 90fbb870a4451098ddafc9555698430820a2078cc0e453e04978cec81ce80affc21b8323bef84fc0b3a2b8cc54e56d765034c746c4347c85acf16f73563cced7
7
+ data.tar.gz: 1740ae1b6c65fae06179e612032bf02656429b43f95414f351e15c87846af0785475e143dcb9f93eb803b3a2944d61929efa55ec9fb374ec84c465fa9149c5ac
data/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
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
+
16
+ ## [0.2.1]
17
+
18
+ ### Fixed
19
+ - The app no longer fails to boot with `uninitialized constant
20
+ HotwireClub::Toolbox::OptimisticFormHelper` when another gem loads
21
+ `ActionView::Base` before the app initializes (prawn-rails does, during
22
+ `Bundler.require`). The engine's `on_load(:action_view)` hook then runs
23
+ immediately, before the main autoloader is set up. The engine's own
24
+ `app/helpers` directory is now managed by the once autoloader, which is
25
+ available during initialization. Nothing else moves: the host app's helpers
26
+ and other engines stay on the main autoloader. The only consequence is that
27
+ the toolbox's helpers are no longer reloaded in development, which suits
28
+ modules mixed into the never-reloaded `ActionView::Base`.
29
+
5
30
  ## [0.2.0]
6
31
 
7
32
  ### Changed
@@ -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,6 +1,11 @@
1
1
  module HotwireClub
2
2
  module Toolbox
3
3
  class Engine < ::Rails::Engine
4
+ # The helpers below are included into ActionView::Base, which some gems
5
+ # load before the app initializes; the hook then runs at once, before the
6
+ # main autoloader exists. The once autoloader is already set up by then.
7
+ paths["app/helpers"].autoload_once!
8
+
4
9
  # Make the engine's view helpers available in the host app's views.
5
10
  # (The engine intentionally does not isolate its namespace.)
6
11
  initializer "hotwire_club.toolbox.helpers" do
@@ -1,5 +1,5 @@
1
1
  module HotwireClub
2
2
  module Toolbox
3
- VERSION = "0.2.0"
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.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Rubisch