Skip to content

Commit

Permalink
Merge pull request #1212 from priyang12/Pagination
Browse files Browse the repository at this point in the history
Focus state being reset Fixes  #1040
  • Loading branch information
pavish committed Mar 22, 2022
2 parents 4be6ffe + cd6dcce commit 0269ad4
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte';
import { tick, createEventDispatcher } from 'svelte';
import {
faAngleDoubleLeft,
faAngleDoubleRight,
Expand Down Expand Up @@ -46,14 +46,17 @@
$: pageCount = Math.ceil(total / pageSize);
$: pageInfo = calculatePages(currentPage, pageCount);
function setPage(e: Event, _page: number) {
async function setPage(e: Event, _page: number) {
if (_page > 0 && _page <= pageCount && currentPage !== _page) {
currentPage = _page;
dispatch('change', {
currentPage,
originalEvent: e,
});
}
await tick();
const pagebutton = document.querySelector(`[data-page="${currentPage}"]`);
(pagebutton as HTMLElement)?.focus();
}
</script>

Expand Down Expand Up @@ -125,6 +128,7 @@
: `Goto Page ${_page}`}
aria-selected={currentPage === _page}
on:click={(e) => setPage(e, _page)}
data-page={_page}
data-tinro-ignore
>
{_page}
Expand All @@ -138,6 +142,7 @@
: `Goto Page ${_page}`}
class="page"
on:click={(e) => setPage(e, _page)}
data-page={_page}
aria-selected={currentPage === _page}
>
{_page}
Expand Down

0 comments on commit 0269ad4

Please sign in to comment.