-
Notifications
You must be signed in to change notification settings - Fork 102
Description
Up until recent versions I was able to render a flash message with a link in it:
conn
|> Phoenix.Controller.put_flash(
:info,
[
gettext(
"This site is not available to you until you ACTIVATE your registered account. Please check your email for an activation link. Missing an email? Request a new one "
),
link(gettext("HERE"), to: Sct.Linker.base() <> "/users/activate"),
"."
]
)the alert was:
<.alert
color="info"
class="mb-5"
label={Phoenix.Flash.get(@flash, :info)}
phx-click="lv:clear-flash"
phx-value-key="info"
/>However (my inference with the addition of the aria tags) it now fails in this code in the petal_components/helpers.
** (FunctionClauseError) no function clause matching in String.downcase/2
(elixir 1.17.1) lib/string.ex:913: String.downcase(["This site is not available to you until you ACTIVATE your registered account. Please check your email for an activation link. Missing an email? Request a new one ", {:safe, [60, "a", [32, "href", 61, 34, "https://test-2.schellingpoint.com/users/activate", 34], 62, "HERE", 60, 47, "a", 62]}, "."], :default)
(petal_components 2.3.0) lib/petal_components/helpers.ex:25: PetalComponents.Helpers.uniq_id/2
(petal_components 2.3.0) lib/petal_components/alert.ex:35: PetalComponents.Alert."alert (overridable 1)"/1
(phoenix_live_view 0.20.17) lib/phoenix_live_view/tag_engine.ex:92: Phoenix.LiveView.TagEngine.component/3
(sct 2.0.249) lib/sct_web/components/layouts/body.html.heex:4: anonymous fn/2 in SctWeb.Layouts.body/1
...
As far as I can see this is due to the generation of a uniq_id with the assumption that the label is solely a String. Which in the case of a safe raw string it is not.
I am under the impression that the construction of a flash message as to how I am doing it is acceptable in Phoenix. I have tried a number of methods working around this, however I either end up with something that is IO like and fails now, or it is a string and renders the HTML itself not as HTML.
My "workaround" was finally to alter code to the following in use of .alert
<.alert
:if={Phoenix.Flash.get(@flash, :info)}
color="info"
class="mb-5"
label="alert-info-label"
phx-click="lv:clear-flash"
phx-value-key="info"
>
<%= Phoenix.Flash.get(@flash, :info) %>
</.alert>
The above sidesteps the attempt to generate a uniq_id from the label.
I believe this is a bug introduced recently (prior to 2.2.1) . I also believe it could/should be handled in the uniq_id code.
OTP 27
Elixir 1.7.3