Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render modal even if its not open #79

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions lib/backpex/html/layout.ex
Original file line number Diff line number Diff line change
Expand Up @@ -440,10 +440,13 @@ defmodule Backpex.HTML.Layout do
|> assign(:classes, get_modal_classes(assigns))

~H"""
<div :if={@open} id="modal">
<div id="modal">
<div
id="modal-overlay"
class="animate-fade-in fixed inset-0 z-50 bg-gray-900 bg-opacity-30 transition-opacity"
class={[
"animate-fade-in fixed inset-0 z-50 bg-gray-900 bg-opacity-30 transition-opacity",
unless(@open, do: "hidden")
]}
aria-hidden="true"
>
</div>
Expand All @@ -458,9 +461,9 @@ defmodule Backpex.HTML.Layout do
>
<div
class={@classes}
phx-click-away={hide_modal(@target, @close_event_name)}
phx-window-keydown={hide_modal(@target, @close_event_name)}
phx-key="escape"
phx-click-away={@open && hide_modal(@target, @close_event_name)}
phx-window-keydown={@open && hide_modal(@target, @close_event_name)}
phx-key={@open && "escape"}
>
<!-- Header -->
<div class="border-b border-gray-100 px-5 py-3">
Expand Down
Loading