mirror of
https://github.com/fly-apps/live_beats.git
synced 2024-12-22 15:16:28 +00:00
Fix 'navigate' link to use live_redirect and support keyboard navigation
This commit is contained in:
parent
f1908151f9
commit
597df89b41
1 changed files with 9 additions and 5 deletions
|
@ -122,13 +122,17 @@ defmodule LiveBeatsWeb.LiveHelpers do
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
|
|
||||||
def link(%{navigate: _to} = assigns) do
|
def link(%{navigate: to} = assigns) do
|
||||||
assigns = assign_new(assigns, :class, fn -> nil end)
|
opts =
|
||||||
|
assigns
|
||||||
|
|> assign_new(:class, fn -> nil end)
|
||||||
|
|> assigns_to_attributes([:navigate])
|
||||||
|
|> Keyword.put(:to, to)
|
||||||
|
|
||||||
|
assigns = assign(assigns, :opts, opts)
|
||||||
|
|
||||||
~H"""
|
~H"""
|
||||||
<a href={@navigate} data-phx-link="redirect" data-phx-link-state="push" class={@class}>
|
<%= live_redirect @opts do %><%= render_slot(@inner_block) %><% end %>
|
||||||
<%= render_slot(@inner_block) %>
|
|
||||||
</a>
|
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue