Add auto-save to the draft comment field

This commit is contained in:
Kevin McConnell
2025-02-13 15:16:42 +00:00
parent 85749687f7
commit cd9fce9b89
2 changed files with 16 additions and 2 deletions
@@ -0,0 +1,13 @@
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static outlets = [ "auto-save" ]
change(event) {
this.autoSaveOutlet.change(event)
}
submit() {
this.autoSaveOutlet.submit()
}
}
+3 -2
View File
@@ -101,8 +101,9 @@
<% if @bubble.published? %>
<%= render "bubbles/messages", bubble: @bubble %>
<% else %>
<form>
<%= tag.house_md @bubble.draft_comment, name: "bubble[draft_comment]", form: "bubble_form", placeholder: new_comment_placeholder(@bubble) %>
<form data-controller="remote-auto-save" data-remote-auto-save-auto-save-outlet="#bubble_form">
<%= tag.house_md @bubble.draft_comment, name: "bubble[draft_comment]", form: "bubble_form", placeholder: new_comment_placeholder(@bubble),
data: { action: "house-md:change->remote-auto-save#change focusout->remote-auto-save#submit" } %>
</form>
<% end %>
</div>