diff --git a/web/src/components/FileBrowser/FileBrowserPagination.vue b/web/src/components/FileBrowser/FileBrowserPagination.vue index 382142b38..6b110251e 100644 --- a/web/src/components/FileBrowser/FileBrowserPagination.vue +++ b/web/src/components/FileBrowser/FileBrowserPagination.vue @@ -19,10 +19,9 @@ mdi-chevron-left + of {{ pageCount }} diff --git a/web/src/views/FileBrowserView/FileBrowser.vue b/web/src/views/FileBrowserView/FileBrowser.vue index 247916b5e..aec7e9d48 100644 --- a/web/src/views/FileBrowserView/FileBrowser.vue +++ b/web/src/views/FileBrowserView/FileBrowser.vue @@ -246,7 +246,7 @@ v-if="currentDandiset.asset_count" :page="page" :page-count="pages" - @changePage="page = $event;" + @changePage="changePage($event)" /> @@ -437,9 +437,10 @@ function showDelete(item: AssetPath) { async function getItems() { updating.value = true; let resp; + const currentPage = Number(route.query.page) || page.value; try { resp = await dandiRest.assetPaths( - props.identifier, props.version, location.value, page.value, FILES_PER_PAGE, + props.identifier, props.version, location.value, currentPage, FILES_PER_PAGE, ); } catch (e) { if (axios.isAxiosError(e) && e.response?.status === 404) { @@ -502,7 +503,7 @@ watch(location, () => { if (existingLocation === location.value) { return; } router.push({ ...route, - query: { location: location.value }, + query: { location: location.value, page: String(page.value) }, } as RawLocation); }); @@ -518,8 +519,13 @@ watch(() => route.query, (newRouteQuery) => { getItems(); }, { immediate: true }); -// fetch new page of items when a new one is selected -watch(page, getItems); +function changePage(newPage: number) { + page.value = newPage; + router.push({ + ...route, + query: { location: location.value, page: String(page.value) }, + } as RawLocation); +} // Fetch dandiset if necessary onMounted(() => {