host: relate/unrelate keep both lists in sync (add to current list, never blank the picker)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 30s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 30s
Two reported bugs on the edit page's relation editor:
1. relating a candidate didn't add it to the current-relations list (the AJAX
relate just deleted the candidate row; the relation only showed after a reload);
2. removing a relation could blank the relate picker.
Fix (lib/host/blog.sx): both the candidate's relate form and a current relation's
remove form now target #rel-editor-<kind> with sx-swap=outerHTML, and the
relate/unrelate handlers return the re-rendered editor for that kind (current list +
a fresh picker). So one swap keeps BOTH lists in sync: the related post moves into
the current list and out of the (re-loaded) candidate pool; removing moves it back.
Gated on the SX-Target header, so a plain boosted form / no-JS POST (the is-a-tag
toggle) still redirects + re-renders #content.
Engine fix (web/orchestration.sx): handle-html-response's non-select branch called
post-swap on the OLD target, which an outerHTML swap has already REPLACED — so the
swapped-in content's triggers (here the re-rendered picker's "load") never bound and
the picker stayed empty. post-swap the swap result (the new node), mirroring the
sx-select branch. Recompiled orchestration.sxbc for the content-addressed client.
Tests:
- web/tests/test-relate-picker.sx: relating re-syncs the editor (post in current
list + picker re-loads); removing does likewise — both fail without the engine fix.
- lib/host/tests/blog.sx: relate/unrelate return the re-rendered editor fragment
(200, #rel-editor + picker), forms wire to #rel-editor-KIND/outerHTML, plain
boosted POST still 303.
- relate-picker.spec.js: the full in-page flow (relate adds to list, remove keeps
the picker, no reload) + persistence.
Verified: host conformance 277/277, web engine suite 8/8, run-picker-check 3/3,
run-spa-check 3/3.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -467,11 +467,19 @@
|
||||
use-transition
|
||||
(fn
|
||||
()
|
||||
(swap-dom-nodes
|
||||
target
|
||||
(children-to-fragment container)
|
||||
swap-style)
|
||||
(post-swap target))))))))))
|
||||
;; post-swap the NEW node, not the old target — an outerHTML
|
||||
;; swap REPLACES target, so processing target would re-bind a
|
||||
;; detached node and leave the swapped-in content's triggers
|
||||
;; (e.g. a re-rendered picker's "load") unbound. Mirrors the
|
||||
;; sx-select branch above. For innerHTML swap-root falls back
|
||||
;; to target (still in the document).
|
||||
(let
|
||||
((swap-root
|
||||
(swap-dom-nodes
|
||||
target
|
||||
(children-to-fragment container)
|
||||
swap-style)))
|
||||
(post-swap (or swap-root target))))))))))))
|
||||
(define
|
||||
handle-retry
|
||||
:effects (mutation io)
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user