phlex-reactive 0.2.4 → 0.2.5
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 +4 -4
- data/CHANGELOG.md +18 -1
- data/app/javascript/phlex/reactive/reactive_controller.js +13 -7
- data/lib/phlex/reactive/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 83d418e64d127a079e74679e4920d85803fedff629e8d8b135c2896a79b5bbdd
|
|
4
|
+
data.tar.gz: 16c68638d96348ea94c0fa25d411486e49c0b2dab01f07fe9e67fefba630a537
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cc16a212daaeb236631702db89fe846dabf936d532e18919c0a371d408f29ce94ae94028eff8cc82e3ff66f1ee25a8acb75f2df29f0b1e2ceb819e49ee3b7217
|
|
7
|
+
data.tar.gz: 0b9721189cb032d6a91ae163b15742cb1cb163ef93da4b5ced1d4382811b43da5b5ba3ea25041b5919b20fb58d2dd4d582d8c1ba1345b6d8accf7ac94cdeb978
|
data/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,22 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
8
8
|
|
|
9
9
|
### Fixed
|
|
10
10
|
|
|
11
|
+
- **Form submit navigated instead of running the reactive action.** A component
|
|
12
|
+
wired with `on(:save, event: "submit")` on a real `<form>` let the browser
|
|
13
|
+
submit natively (full POST to the form's `action`), because
|
|
14
|
+
`dispatch()` deferred `event.preventDefault()` into the request-queue microtask
|
|
15
|
+
— too late, since `preventDefault()` only works synchronously within the event
|
|
16
|
+
dispatch. For `click` triggers there's no default to miss, so it was invisible;
|
|
17
|
+
for `submit` the form navigated (e.g. `POST /` → routing error). `dispatch()`
|
|
18
|
+
now calls `preventDefault()` synchronously (and captures the action/params up
|
|
19
|
+
front, so the deferred work never re-reads a reset event object). Guarded by a
|
|
20
|
+
bun unit test (`spec/javascript/reactive_controller.test.js`) that asserts the
|
|
21
|
+
synchronous call and fails on the pre-fix deferred code. Closes #11.
|
|
22
|
+
|
|
23
|
+
## [0.2.4] - 2026-06-24
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
|
|
11
27
|
- **Reactive save silently dropped rich-text / custom-editor fields.** The
|
|
12
28
|
client's field auto-collection (`#collectFields`) queried only
|
|
13
29
|
`input[name], select[name], textarea[name]`, so a named rich-text editor
|
|
@@ -123,7 +139,8 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
123
139
|
scaffolds a reactive component (and an RSpec spec when the app uses RSpec),
|
|
124
140
|
state-backed by default or record-backed with `--record`.
|
|
125
141
|
|
|
126
|
-
[Unreleased]: https://github.com/mhenrixon/phlex-reactive/compare/v0.2.
|
|
142
|
+
[Unreleased]: https://github.com/mhenrixon/phlex-reactive/compare/v0.2.3...HEAD
|
|
143
|
+
[0.2.4]: https://github.com/mhenrixon/phlex-reactive/compare/v0.2.3...v0.2.4
|
|
127
144
|
[0.2.3]: https://github.com/mhenrixon/phlex-reactive/compare/v0.2.2...v0.2.3
|
|
128
145
|
[0.2.2]: https://github.com/mhenrixon/phlex-reactive/compare/v0.2.1...v0.2.2
|
|
129
146
|
[0.2.1]: https://github.com/mhenrixon/phlex-reactive/compare/v0.2.0...v0.2.1
|
|
@@ -34,18 +34,24 @@ export default class extends Controller {
|
|
|
34
34
|
// a per-controller promise makes each dispatch wait for the previous one, so
|
|
35
35
|
// it always uses the freshest token.
|
|
36
36
|
dispatch(event) {
|
|
37
|
-
this.queue = (this.queue ?? Promise.resolve()).then(() => this.#perform(event))
|
|
38
|
-
return this.queue
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async #perform(event) {
|
|
42
37
|
const { action, params } = event.params
|
|
43
38
|
if (!action) return
|
|
44
39
|
|
|
45
|
-
// Stop native behavior (button submit /
|
|
46
|
-
//
|
|
40
|
+
// Stop native behavior (button submit / FORM NAVIGATION) HERE, synchronously
|
|
41
|
+
// within the event dispatch. preventDefault() only works while the event is
|
|
42
|
+
// still being handled — deferring it into the request-queue microtask (below)
|
|
43
|
+
// is too late: a `submit` trigger would natively POST the form and navigate
|
|
44
|
+
// before the reactive round trip runs (issue #11). For a `click` trigger
|
|
45
|
+
// there's no default to miss, so this was previously invisible.
|
|
47
46
|
event.preventDefault()
|
|
48
47
|
|
|
48
|
+
// Capture action/params now; the queued work runs in a later microtask, by
|
|
49
|
+
// which point the event object may have been reset by the browser.
|
|
50
|
+
this.queue = (this.queue ?? Promise.resolve()).then(() => this.#perform(action, params))
|
|
51
|
+
return this.queue
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async #perform(action, params) {
|
|
49
55
|
// Auto-collect named field values inside this component so a button-
|
|
50
56
|
// triggered action still receives sibling inputs (Livewire-style).
|
|
51
57
|
// Explicit params (data-reactive-params-param) win over collected fields.
|