Skip to content

Commit

Permalink
assign generated id
Browse files Browse the repository at this point in the history
  • Loading branch information
chulkilee committed Aug 6, 2023
1 parent e343782 commit 69504a5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion installer/templates/phx_web/components/core_components.ex
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,11 @@ defmodule <%= @web_namespace %>.CoreComponents do
slot :inner_block, doc: "the optional inner block that renders the flash message"

def flash(assigns) do
assigns = assign(assigns, :id, assigns.id || "flash-#{assigns.kind}")
~H"""
<div
:if={msg = render_slot(@inner_block) || Phoenix.Flash.get(@flash, @kind)}
id={@id || "flash-#{@kind}"}
id={@id}
phx-click={JS.push("lv:clear-flash", value: %{key: @kind}) |> hide("##{@id}")}
role="alert"
class={[
Expand Down
3 changes: 2 additions & 1 deletion priv/templates/phx.gen.live/core_components.ex
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,11 @@ defmodule <%= @web_namespace %>.CoreComponents do
slot :inner_block, doc: "the optional inner block that renders the flash message"

def flash(assigns) do
assigns = assign(assigns, :id, assigns.id || "flash-#{assigns.kind}")
~H"""
<div
:if={msg = render_slot(@inner_block) || Phoenix.Flash.get(@flash, @kind)}
id={@id || "flash-#{@kind}"}
id={@id}
phx-click={JS.push("lv:clear-flash", value: %{key: @kind}) |> hide("##{@id}")}
role="alert"
class={[
Expand Down

0 comments on commit 69504a5

Please sign in to comment.