From 7e38921e8ae339a1d518b11ede35106643563a1f Mon Sep 17 00:00:00 2001 From: Adam Piontek Date: Tue, 9 Mar 2021 10:48:23 -0500 Subject: [PATCH] fixing duplicate input element id issue --- lib/shift73k_web/live/user/settings/email.html.leex | 7 +++---- lib/shift73k_web/live/user/settings/password.html.leex | 7 +++---- lib/shift73k_web/views/error_helpers.ex | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/shift73k_web/live/user/settings/email.html.leex b/lib/shift73k_web/live/user/settings/email.html.leex index d50ce902..a3e773a2 100644 --- a/lib/shift73k_web/live/user/settings/email.html.leex +++ b/lib/shift73k_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/shift73k_web/live/user/settings/password.html.leex b/lib/shift73k_web/live/user/settings/password.html.leex index a15d30ff..3041c660 100644 --- a/lib/shift73k_web/live/user/settings/password.html.leex +++ b/lib/shift73k_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/shift73k_web/views/error_helpers.ex b/lib/shift73k_web/views/error_helpers.ex index 76b8145b..3b5c2470 100644 --- a/lib/shift73k_web/views/error_helpers.ex +++ b/lib/shift73k_web/views/error_helpers.ex @@ -23,13 +23,13 @@ defmodule Shift73kWeb.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}"