From 4a367a6de65f4c716b26954f95593373f7f62733 Mon Sep 17 00:00:00 2001 From: Adam Piontek Date: Tue, 9 Mar 2021 10:48:02 -0500 Subject: [PATCH] fixing duplicate input element id issue --- lib/bones73k_web/live/user/settings/email.html.leex | 7 +++---- lib/bones73k_web/live/user/settings/password.html.leex | 7 +++---- lib/bones73k_web/views/error_helpers.ex | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/bones73k_web/live/user/settings/email.html.leex b/lib/bones73k_web/live/user/settings/email.html.leex index d50ce90..a3e773a 100644 --- a/lib/bones73k_web/live/user/settings/email.html.leex +++ b/lib/bones73k_web/live/user/settings/email.html.leex @@ -19,14 +19,13 @@ <%= label f, :current_password, class: "form-label" %> -
+
<%= icon_div @socket, "bi-lock", [class: "icon is-left text-muted fs-5"] %> <%= password_input f, :current_password, value: input_value(f, :current_password), - class: "form-control", - aria_describedby: error_ids(f, :current_password) + id: "user_email_current_password", + class: "form-control" %> - <%= error_tag f, :current_password %>
diff --git a/lib/bones73k_web/live/user/settings/password.html.leex b/lib/bones73k_web/live/user/settings/password.html.leex index eca8b96..9815074 100644 --- a/lib/bones73k_web/live/user/settings/password.html.leex +++ b/lib/bones73k_web/live/user/settings/password.html.leex @@ -30,14 +30,13 @@
<%= label f, :current_password, class: "form-label" %> -
+
<%= icon_div @socket, "bi-lock", [class: "icon is-left text-muted fs-5"] %> <%= password_input f, :current_password, value: input_value(f, :current_password), - class: "form-control", - aria_describedby: error_ids(f, :current_password) + id: "user_password_current_password", + class: "form-control" %> - <%= error_tag f, :current_password %>
diff --git a/lib/bones73k_web/views/error_helpers.ex b/lib/bones73k_web/views/error_helpers.ex index abe52ed..3ec68f6 100644 --- a/lib/bones73k_web/views/error_helpers.ex +++ b/lib/bones73k_web/views/error_helpers.ex @@ -23,13 +23,13 @@ defmodule Bones73kWeb.ErrorHelpers do end defp error_common_opts(form, field, append, opts) do - Keyword.put(opts, :phx_feedback_for, input_id(form, field)) + Keyword.put_new(opts, :phx_feedback_for, input_id(form, field)) |> Keyword.update(:class, append, fn c -> "#{append} #{c}" end) end defp error_tag_opts({_err, err_index}, opts) do input_id = Keyword.get(opts, :phx_feedback_for, "") - Keyword.put(opts, :id, error_id(input_id, err_index)) + Keyword.put_new(opts, :id, error_id(input_id, err_index)) end defp error_id(input_id, err_index), do: "#{input_id}_feedback-#{err_index}"