From c60108292a3c9f9f476ddbe81e08df714cdfc705 Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Mon, 16 Dec 2024 18:03:26 +0000 Subject: [PATCH] Scroll to top when paginating on small viewports --- lib/music_library_web/components/pagination.ex | 2 ++ priv/gettext/default.pot | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/music_library_web/components/pagination.ex b/lib/music_library_web/components/pagination.ex index dad6e9b4..cabc8e6b 100644 --- a/lib/music_library_web/components/pagination.ex +++ b/lib/music_library_web/components/pagination.ex @@ -26,6 +26,7 @@ defmodule MusicLibraryWeb.Pagination do <.link :if={@page_links.prev_page} patch={"?" <> encode_query(page: @page_links.prev_page, page_size: @pagination_params.page_size, query: @pagination_params.query)} + phx-click={JS.dispatch("music_library:scroll_top")} class={[ "relative inline-flex items-center rounded-md border", "px-3 py-2 text-sm font-medium", @@ -39,6 +40,7 @@ defmodule MusicLibraryWeb.Pagination do <.link :if={@page_links.next_page} patch={"?" <> encode_query(page: @page_links.next_page, page_size: @pagination_params.page_size, query: @pagination_params.query)} + phx-click={JS.dispatch("music_library:scroll_top")} class={[ "relative ml-3 inline-flex items-center rounded-md border", "px-3 py-2 text-sm font-medium", diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index 6b158b5e..447d0589 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -155,8 +155,8 @@ msgstr "" msgid "MusicBrainz ID" msgstr "" -#: lib/music_library_web/components/pagination.ex:50 -#: lib/music_library_web/components/pagination.ex:114 +#: lib/music_library_web/components/pagination.ex:52 +#: lib/music_library_web/components/pagination.ex:116 #, elixir-autogen, elixir-format msgid "Next" msgstr "" @@ -183,8 +183,8 @@ msgstr "" msgid "Password" msgstr "" -#: lib/music_library_web/components/pagination.ex:37 -#: lib/music_library_web/components/pagination.ex:137 +#: lib/music_library_web/components/pagination.ex:38 +#: lib/music_library_web/components/pagination.ex:139 #, elixir-autogen, elixir-format msgid "Previous" msgstr ""