diff --git a/CHANGELOG.md b/CHANGELOG.md
index cc862e61..d1a7cfa7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog
+## 0.5.4
+
+Fixed a bug where the required marker would always be displayed, regardless of the field's required state.
+
## 0.5.3
Downgraded `phoenix_live_view` version to `0.19`; both `0.19` and `0.20` should be compatible.
diff --git a/assets/package.json b/assets/package.json
index 62383fc8..c3dbe6de 100644
--- a/assets/package.json
+++ b/assets/package.json
@@ -1,6 +1,6 @@
{
"name": "primer-live",
- "version": "0.5.3",
+ "version": "0.5.4",
"description": "JavaScript and CSS for PrimerLive",
"license": "MIT",
"repository": {},
diff --git a/lib/component.ex b/lib/component.ex
index 1cc1dc8f..e7828044 100644
--- a/lib/component.ex
+++ b/lib/component.ex
@@ -2906,7 +2906,8 @@ defmodule PrimerLive.Component do
form: form,
field: field,
validation_marker_class: validation_marker_class,
- caption: caption
+ caption: caption,
+ required?: required?
} = AttributeHelpers.common_input_attrs(assigns)
classes = %{
@@ -2973,7 +2974,9 @@ defmodule PrimerLive.Component do
end
has_header_label = label && label !== "Nil"
- has_required_marker = !is_nil(assigns.required_marker) && assigns.required_marker !== ""
+
+ show_required_marker =
+ required? && !is_nil(assigns.required_marker) && assigns.required_marker !== ""
control_attributes =
AttributeHelpers.append_attributes(rest, [
@@ -2985,7 +2988,7 @@ defmodule PrimerLive.Component do
|> assign(:classes, classes)
|> assign(:control_attributes, control_attributes)
|> assign(:has_header_label, has_header_label)
- |> assign(:has_required_marker, has_required_marker)
+ |> assign(:show_required_marker, show_required_marker)
|> assign(:label, label)
|> assign(:caption, caption)
@@ -2994,7 +2997,7 @@ defmodule PrimerLive.Component do
<%= if @has_header_label do %>
@@ -7152,14 +7155,9 @@ defmodule PrimerLive.Component do
PromptDeclarationHelpers.prompt_options()
PromptDeclarationHelpers.phx_click_touch()
PromptDeclarationHelpers.toggle_slot("the select menu component")
-
- attr(:is_aligned_end, :boolean,
- default: false,
- doc: "Aligns the menu to the end (at the right in left-to-right langages)."
- )
+ DeclarationHelpers.is_aligned_end("the menu")
attr(:is_right_aligned, :boolean, doc: "Deprecated: use `is_aligned_end`. Since 0.5.1.")
-
attr(:is_borderless, :boolean, default: false, doc: "Removes the borders between list items.")
DeclarationHelpers.class()
@@ -7791,8 +7789,7 @@ defmodule PrimerLive.Component do
PromptDeclarationHelpers.prompt_options()
PromptDeclarationHelpers.phx_click_touch()
PromptDeclarationHelpers.toggle_slot("the menu component")
-
- attr(:is_aligned_end, :boolean, default: false, doc: "Aligns the menu to the right.")
+ DeclarationHelpers.is_aligned_end("the menu")
attr(:is_right_aligned, :boolean, doc: "Deprecated: use `is_aligned_end`. Since 0.5.1.")
diff --git a/lib/helpers/attribute_helpers.ex b/lib/helpers/attribute_helpers.ex
index 1f039f1f..5cccfecb 100644
--- a/lib/helpers/attribute_helpers.ex
+++ b/lib/helpers/attribute_helpers.ex
@@ -697,6 +697,7 @@ defmodule PrimerLive.Helpers.AttributeHelpers do
%{
message: message,
valid?: valid?,
+ required?: required?,
ignore_errors?: ignore_errors?,
caption: caption
} = field_state
@@ -736,6 +737,7 @@ defmodule PrimerLive.Helpers.AttributeHelpers do
%{
message: message,
valid?: valid?,
+ required?: required?,
ignore_errors?: ignore_errors?,
show_message?: show_message?,
validation_message_id: validation_message_id,
diff --git a/lib/helpers/declaration_helpers.ex b/lib/helpers/declaration_helpers.ex
index 129c1ddd..999745c6 100644
--- a/lib/helpers/declaration_helpers.ex
+++ b/lib/helpers/declaration_helpers.ex
@@ -187,6 +187,19 @@ defmodule PrimerLive.Helpers.DeclarationHelpers do
end
end
+ defmacro is_aligned_end(the_element) do
+ quote do
+ attr(:is_aligned_end, :boolean,
+ default: false,
+ doc:
+ """
+ Aligns {the_element} to the end (at the right in left-to-right languages).
+ """
+ |> String.replace("{the_element}", unquote(the_element))
+ )
+ end
+ end
+
# link attr
defmacro href do
diff --git a/mix.exs b/mix.exs
index 5d0d3a55..f5ef75c7 100644
--- a/mix.exs
+++ b/mix.exs
@@ -4,7 +4,7 @@ defmodule PrimerLive.MixProject do
def project do
[
app: :primer_live,
- version: "0.5.3",
+ version: "0.5.4",
homepage_url: "https://github.com/ArthurClemens/primer_live",
description: description(),
package: package(),
diff --git a/package-lock.json b/package-lock.json
index 5db29ff6..8db88cdd 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "primer-live",
- "version": "0.5.3",
+ "version": "0.5.4",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "primer-live",
- "version": "0.5.3",
+ "version": "0.5.4",
"license": "MIT"
}
}
diff --git a/package.json b/package.json
index 05289820..579ea1fe 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "primer-live",
- "version": "0.5.3",
+ "version": "0.5.4",
"description": "JavaScript and CSS for PrimerLive",
"license": "MIT",
"module": "./priv/static/primer-live.esm.js",
diff --git a/test/components/checkbox_group_test.exs b/test/components/checkbox_group_test.exs
index d12ed61e..9092dbe9 100644
--- a/test/components/checkbox_group_test.exs
+++ b/test/components/checkbox_group_test.exs
@@ -79,7 +79,7 @@ defmodule PrimerLive.TestComponents.CheckboxGroupTest do
"""