Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurClemens committed Aug 3, 2024
1 parent c484dcf commit bf5d16f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
6 changes: 5 additions & 1 deletion lib/component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11272,7 +11272,11 @@ defmodule PrimerLive.Component do
PromptDeclarationHelpers.is_escapable()
PromptDeclarationHelpers.focus_first("the dialog")

attr(:is_show_on_mount, :boolean, default: false)
attr(:is_show_on_mount, :boolean,
default: false,
doc:
"Displays the dialog on mount. Control conditional display by using the regular `:if={}` attribute."
)

DeclarationHelpers.class()

Expand Down
34 changes: 32 additions & 2 deletions lib/helpers/attribute_helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,36 @@ defmodule PrimerLive.Helpers.AttributeHelpers do
touch_layer_attrs: ["data-touch": ""]
}
With is_show_on_mount:
iex> PrimerLive.Helpers.AttributeHelpers.prompt_attrs(
...> %{
...> rest: %{
...> id: "some-id"
...> },
...> prompt_options: nil,
...> is_fast: false,
...> is_dark_backdrop: false,
...> is_medium_backdrop: false,
...> is_light_backdrop: false,
...> is_show_on_mount: true
...> },
...> %{
...> form: nil,
...> field: nil,
...> toggle_slot: nil,
...> toggle_class: "btn",
...> menu_class: "",
...> is_menu: false
...> })
%{
backdrop_attrs: [],
checkbox_attrs: [{:"aria-hidden", "true"}, {:checked, true}, {:hidden_input, false}, {:id, "some-id-toggle"}, {:onchange, "window.Prompt && Prompt.change(this)"}],
focus_wrap_id: "focus-wrap-some-id",
menu_attrs: [class: "", "data-prompt": "", id: "some-id", "phx-hook": "Prompt"],
toggle_attrs: [{:"aria-haspopup", "true"}, {:class, "btn"}, {:for, "some-id-toggle"}],
touch_layer_attrs: ["data-touch": ""]
}
phx_click_touch:
iex> PrimerLive.Helpers.AttributeHelpers.prompt_attrs(
...> %{
Expand Down Expand Up @@ -990,7 +1020,6 @@ defmodule PrimerLive.Helpers.AttributeHelpers do
append_attributes([
[
id: toggle_id,
checked: assigns[:is_show_on_mount],
"aria-hidden": "true",
# Only use the default extra hidden input when using the menu inside a form
hidden_input: !is_nil(field),
Expand All @@ -1003,7 +1032,8 @@ defmodule PrimerLive.Helpers.AttributeHelpers do
")"
]
|> Enum.join("")
]
],
if(assigns[:is_show_on_mount], do: [checked: true], else: nil)
])

menu_id = id || "menu-" <> toggle_id
Expand Down

0 comments on commit bf5d16f

Please sign in to comment.