Use the new required attribute that now Lexxy supports
This commit is contained in:
+1
-1
@@ -359,7 +359,7 @@ GEM
|
||||
logger (~> 1.6)
|
||||
letter_opener (1.10.0)
|
||||
launchy (>= 2.2, < 4)
|
||||
lexxy (0.1.9.beta)
|
||||
lexxy (0.1.10.beta)
|
||||
rails (>= 8.0.2)
|
||||
lint_roller (1.1.0)
|
||||
logger (1.7.0)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
import { debounce } from "helpers/timing_helpers";
|
||||
import { debounce, nextFrame } from "helpers/timing_helpers";
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = [ "cancel", "submit" ]
|
||||
@@ -37,13 +37,13 @@ export default class extends Controller {
|
||||
event.preventDefault()
|
||||
}
|
||||
|
||||
disableEmptySubmit(event) {
|
||||
var value = event.target.value.replace(/<\/?[^>]+(>|$)/g, "")
|
||||
async disableSubmitWhenInvalid(event) {
|
||||
await nextFrame()
|
||||
|
||||
if (value) {
|
||||
if (this.element.checkValidity()) {
|
||||
this.submitTarget.removeAttribute("disabled")
|
||||
} else {
|
||||
this.submitTarget.setAttribute("disabled", true)
|
||||
this.submitTarget.toggleAttribute("disabled", true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
local_save_key_value: "comment-#{card.id}",
|
||||
action: "turbo:submit-end->local-save#submit keydown.ctrl+enter->form#submit:prevent keydown.meta+enter->form#submit:prevent keydown.esc->form#cancel:stop" } do |form| %>
|
||||
<%= form.rich_textarea :body, required: true, placeholder: new_comment_placeholder(card),
|
||||
data: { local_save_target: "input", action: "lexxy:change->form#disableEmptySubmit lexxy:change->local-save#save turbo:morph-element->local-save#restoreContent" } do %>
|
||||
data: { local_save_target: "input", action: "lexxy:change->form#disableSubmitWhenInvalid lexxy:change->local-save#save turbo:morph-element->local-save#restoreContent" } do %>
|
||||
<%= general_prompts(@card.collection) %>
|
||||
<% end %>
|
||||
<%= form.button class: "comment__submit btn btn--reversed flex-item-justify-start", data: { form_target: "submit" }, disabled: true do %>
|
||||
|
||||
Reference in New Issue
Block a user