fix: MPS-24 Phase 2.8b — one unified AJAX click handler for all bulk-tagger actions

Operator: 'same with the delete button. and add' — i.e. Add / Delete
(and reorder) still full-reloaded. The generic data-tag-form
submit-EVENT interception is unreliable in the field; the explicit
click handlers (focus/drag) work. Root fix instead of patching each
button: one capture-phase CLICK handler (onTagFormClick) on every
submit control inside form[data-tag-form].

- onTagFormClick preventDefault()s so the native submit never starts
  (no reload, no double-handling), runs the delete confirm via
  data-confirm, routes reorder -> doReorder (in-place swap), everything
  else (create/add, delete, attach/detach, apply/dismiss suggestion)
  -> submitForm.
- Removed inline onclick="return confirm()" from shop_tags.j2 AND the
  JS appendTagRow builder — it fought the interception; now data-confirm.
- submit listener kept only as the Enter-key fallback. Standalone
  wireReorderButtons folded into onTagFormClick. Dead escapeJs removed.
- Tests: +test_ajax_delete_tag_returns_json,
  +test_bulk_tagger_delete_uses_data_confirm_not_inline_onclick,
  +test_ajax_reorder_arrow_returns_json_and_moves. 1131 passed.

Docs: mps-24.md Phase 2.8b.
This commit is contained in:
russell@unturf.com 2026-05-16 09:05:14 -04:00
parent 155f7ff66f
commit b15c0a0f38
No known key found for this signature in database
4 changed files with 177 additions and 15 deletions

View file

@ -363,6 +363,24 @@ Tests (`test_functional.py::TestProductTagsSpa`):
Deferred (occasional click, not the hot path): AJAX-ifying the
"Suggest categories" link — still a full navigation by design.
**Phase 2.8b** (shipped 2026-05-16): the generic `data-tag-form`
**`submit`-event** interception proved unreliable in the field —
operator reported Add / Delete / reorder *all* still full-reloaded
while the explicit click handlers (focus/drag) worked. Root fix:
**one unified capture-phase `click` handler** (`onTagFormClick`)
on every submit control inside `form[data-tag-form]`. It
`preventDefault()`s (native submit never starts → no reload, no
double-handling), runs the delete confirm via `data-confirm`
(inline `onclick="return confirm()"` removed from `shop_tags.j2`
**and** the JS `appendTagRow` builder — it fought the interception),
routes `reorder``doReorder` (in-place swap) and everything else
(create/add, delete, attach/detach, apply/dismiss suggestion) →
`submitForm`. The `submit` listener is kept only as the Enter-key
fallback; `escapeJs` removed (dead after the onclick→data-confirm
switch). Tests: `test_ajax_reorder_arrow_returns_json_and_moves`,
`test_ajax_delete_tag_returns_json`,
`test_bulk_tagger_delete_uses_data_confirm_not_inline_onclick`.
### Phase 2.7 — per-product SPA tag chips on product edit (shipped 2026-05-16)
Operator report: adding/removing a tag on the product edit page