Fix Create button on new series form
The button used x-on:click (Alpine directive) but had no x-data
ancestor, so Alpine never bound the handler. Moved the click
listener to app.js where the editor is already initialized.
Assisted-by: Claude Opus 4.6 via Claude Code
diff --git a/lib/ketchup/snapshots.rb b/lib/ketchup/snapshots.rb
index 5d247c9..6b0aa82 100644
--- a/lib/ketchup/snapshots.rb
+++ b/lib/ketchup/snapshots.rb
@@ -174,9 +174,8 @@ module Ketchup
# ── Series detail (newly created) ──
- # Submit the new series form directly — the create button
- # triggers requestSubmit(), but we can do it ourselves.
- @browser.evaluate('document.getElementById("new-series-form").requestSubmit()')
+ # Submit via the Create button to exercise the JS click handler
+ wait_for("#create-series-btn").click
wait_for("#series-note-detail")
entries << snap("series-created", selector: ".main-column")
diff --git a/lib/ketchup/views/series/new.rb b/lib/ketchup/views/series/new.rb
index 80d67f3..a5611dc 100644
--- a/lib/ketchup/views/series/new.rb
+++ b/lib/ketchup/views/series/new.rb
@@ -24,12 +24,11 @@ module Views
button(
class: "section-edit-btn",
id: "create-series-btn",
- disabled: true,
- "x-on:click": "document.getElementById('new-series-form').requestSubmit()"
+ disabled: true
) { "Create" }
end
- form(method: "post", action: "/series", id: "new-series-form", class: "new-series-form") do
+ form(method: "post", action: "/series", id: "new-series-form", class: "new-series-form", novalidate: true) do
input(type: "hidden", name: "_csrf", value: @csrf.call("/series"))
div(class: "field") do
label(for: "series-note-editor") { "Note" }
diff --git a/public/js/app.js b/public/js/app.js
index 61e9940..99384a1 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -246,10 +246,14 @@ document.addEventListener("alpine:init", () => {
autoResize: true,
})
const createBtn = document.getElementById("create-series-btn")
- if (createBtn) {
+ const newForm = document.getElementById("new-series-form")
+ if (createBtn && newForm) {
newNoteEl.addEventListener("input", () => {
createBtn.disabled = !editor.getValue().trim()
})
+ createBtn.addEventListener("click", () => {
+ newForm.requestSubmit()
+ })
}
}
})