diff --git a/frontend/src/locales/bg_BG/gallery.json b/frontend/src/locales/bg_BG/gallery.json
index 079732048..57154e997 100644
--- a/frontend/src/locales/bg_BG/gallery.json
+++ b/frontend/src/locales/bg_BG/gallery.json
@@ -1,5 +1,6 @@
{
"all-loaded": "Всички игри са заредени",
+ "back-to-top": "Към началото",
"filters": "Филтри",
"firmware-files-count": "{count} файла",
"firmware-selected-count": "{count} избрани",
diff --git a/frontend/src/locales/cs_CZ/gallery.json b/frontend/src/locales/cs_CZ/gallery.json
index 47e53a273..596ed3335 100644
--- a/frontend/src/locales/cs_CZ/gallery.json
+++ b/frontend/src/locales/cs_CZ/gallery.json
@@ -1,5 +1,6 @@
{
"all-loaded": "Všechny hry byly načteny",
+ "back-to-top": "Zpět nahoru",
"filters": "Filtry",
"firmware-files-count": "{count} souborů",
"firmware-selected-count": "{count} vybráno",
diff --git a/frontend/src/locales/de_DE/gallery.json b/frontend/src/locales/de_DE/gallery.json
index e3fc1da44..7c1207db4 100644
--- a/frontend/src/locales/de_DE/gallery.json
+++ b/frontend/src/locales/de_DE/gallery.json
@@ -1,5 +1,6 @@
{
"all-loaded": "Alle Spiele wurden geladen",
+ "back-to-top": "Nach oben",
"filters": "Filter",
"firmware-files-count": "{count} Dateien",
"firmware-selected-count": "{count} ausgewählt",
diff --git a/frontend/src/locales/en_GB/gallery.json b/frontend/src/locales/en_GB/gallery.json
index cf084c935..4517ee1aa 100644
--- a/frontend/src/locales/en_GB/gallery.json
+++ b/frontend/src/locales/en_GB/gallery.json
@@ -1,5 +1,6 @@
{
"all-loaded": "All games have been loaded",
+ "back-to-top": "Back to top",
"filters": "Filters",
"firmware-files-count": "{count} files",
"firmware-selected-count": "{count} selected",
diff --git a/frontend/src/locales/en_US/gallery.json b/frontend/src/locales/en_US/gallery.json
index 9a7781dc3..69f9cec87 100644
--- a/frontend/src/locales/en_US/gallery.json
+++ b/frontend/src/locales/en_US/gallery.json
@@ -1,5 +1,6 @@
{
"all-loaded": "All games have been loaded",
+ "back-to-top": "Back to top",
"filters": "Filters",
"firmware-files-count": "{count} files",
"firmware-selected-count": "{count} selected",
diff --git a/frontend/src/locales/es_ES/gallery.json b/frontend/src/locales/es_ES/gallery.json
index 6c215a008..aeb876d01 100644
--- a/frontend/src/locales/es_ES/gallery.json
+++ b/frontend/src/locales/es_ES/gallery.json
@@ -1,5 +1,6 @@
{
"all-loaded": "Todos los juegos han sido cargados",
+ "back-to-top": "Volver arriba",
"filters": "Filtros",
"firmware-files-count": "{count} archivos",
"firmware-selected-count": "{count} seleccionados",
diff --git a/frontend/src/locales/fr_FR/gallery.json b/frontend/src/locales/fr_FR/gallery.json
index 7b0cd4799..e304658e9 100644
--- a/frontend/src/locales/fr_FR/gallery.json
+++ b/frontend/src/locales/fr_FR/gallery.json
@@ -1,5 +1,6 @@
{
"all-loaded": "Tous les jeux ont été chargés",
+ "back-to-top": "Retour en haut",
"filters": "Filtres",
"firmware-files-count": "{count} fichiers",
"firmware-selected-count": "{count} sélectionné(s)",
diff --git a/frontend/src/locales/hu_HU/gallery.json b/frontend/src/locales/hu_HU/gallery.json
index 9949047a6..5af967d75 100644
--- a/frontend/src/locales/hu_HU/gallery.json
+++ b/frontend/src/locales/hu_HU/gallery.json
@@ -1,5 +1,6 @@
{
"all-loaded": "Minden játék betöltődött",
+ "back-to-top": "Vissza a tetejére",
"filters": "Szűrők",
"firmware-files-count": "{count} fájl",
"firmware-selected-count": "{count} kiválasztva",
diff --git a/frontend/src/locales/it_IT/gallery.json b/frontend/src/locales/it_IT/gallery.json
index c0aab8eeb..c62e48395 100644
--- a/frontend/src/locales/it_IT/gallery.json
+++ b/frontend/src/locales/it_IT/gallery.json
@@ -1,5 +1,6 @@
{
"all-loaded": "Tutti i giochi sono stati caricati",
+ "back-to-top": "Torna su",
"filters": "Filtri",
"firmware-files-count": "{count} file",
"firmware-selected-count": "{count} selezionati",
diff --git a/frontend/src/locales/ja_JP/gallery.json b/frontend/src/locales/ja_JP/gallery.json
index aeeb2b351..1da882adb 100644
--- a/frontend/src/locales/ja_JP/gallery.json
+++ b/frontend/src/locales/ja_JP/gallery.json
@@ -1,5 +1,6 @@
{
"all-loaded": "すべてのゲームが読み込まれました",
+ "back-to-top": "トップへ戻る",
"filters": "フィルタ",
"firmware-files-count": "{count}件のファイル",
"firmware-selected-count": "{count}件選択中",
diff --git a/frontend/src/locales/ko_KR/gallery.json b/frontend/src/locales/ko_KR/gallery.json
index 336cd930c..ca38f759f 100644
--- a/frontend/src/locales/ko_KR/gallery.json
+++ b/frontend/src/locales/ko_KR/gallery.json
@@ -1,5 +1,6 @@
{
"all-loaded": "모든 게임이 불러와졌습니다",
+ "back-to-top": "맨 위로",
"filters": "필터",
"firmware-files-count": "{count}개 파일",
"firmware-selected-count": "{count}개 선택됨",
diff --git a/frontend/src/locales/pl_PL/gallery.json b/frontend/src/locales/pl_PL/gallery.json
index 5fea0901b..d7a98dbcd 100644
--- a/frontend/src/locales/pl_PL/gallery.json
+++ b/frontend/src/locales/pl_PL/gallery.json
@@ -1,5 +1,6 @@
{
"all-loaded": "Wszystkie gry zostały załadowane",
+ "back-to-top": "Powrót na górę",
"filters": "Filtry",
"firmware-files-count": "{count} plików",
"firmware-selected-count": "{count} wybrano",
diff --git a/frontend/src/locales/pt_BR/gallery.json b/frontend/src/locales/pt_BR/gallery.json
index adaaf9596..c36861e80 100644
--- a/frontend/src/locales/pt_BR/gallery.json
+++ b/frontend/src/locales/pt_BR/gallery.json
@@ -1,5 +1,6 @@
{
"all-loaded": "Todos os jogos foram carregados",
+ "back-to-top": "Voltar ao topo",
"filters": "Filtros",
"firmware-files-count": "{count} arquivos",
"firmware-selected-count": "{count} selecionado(s)",
diff --git a/frontend/src/locales/ro_RO/gallery.json b/frontend/src/locales/ro_RO/gallery.json
index 865db6bde..996aa3597 100644
--- a/frontend/src/locales/ro_RO/gallery.json
+++ b/frontend/src/locales/ro_RO/gallery.json
@@ -1,5 +1,6 @@
{
"all-loaded": "Toate jocurile au fost încărcate",
+ "back-to-top": "Înapoi sus",
"filters": "Filtre",
"firmware-files-count": "{count} fișiere",
"firmware-selected-count": "{count} selectate",
diff --git a/frontend/src/locales/ru_RU/gallery.json b/frontend/src/locales/ru_RU/gallery.json
index d386572f3..a4c1fe40f 100644
--- a/frontend/src/locales/ru_RU/gallery.json
+++ b/frontend/src/locales/ru_RU/gallery.json
@@ -1,5 +1,6 @@
{
"all-loaded": "Все игры загружены",
+ "back-to-top": "Наверх",
"filters": "Фильтры",
"firmware-files-count": "{count} файлов",
"firmware-selected-count": "{count} выбрано",
diff --git a/frontend/src/locales/tr_TR/gallery.json b/frontend/src/locales/tr_TR/gallery.json
index 0e0260d81..d1957f6a7 100644
--- a/frontend/src/locales/tr_TR/gallery.json
+++ b/frontend/src/locales/tr_TR/gallery.json
@@ -1,5 +1,6 @@
{
"all-loaded": "Tüm oyunlar yüklendi",
+ "back-to-top": "Başa dön",
"filters": "Filtreler",
"firmware-files-count": "{count} dosya",
"firmware-selected-count": "{count} seçildi",
diff --git a/frontend/src/locales/zh_CN/gallery.json b/frontend/src/locales/zh_CN/gallery.json
index ed8b62c0a..dc320596e 100644
--- a/frontend/src/locales/zh_CN/gallery.json
+++ b/frontend/src/locales/zh_CN/gallery.json
@@ -1,5 +1,6 @@
{
"all-loaded": "所有游戏已加载",
+ "back-to-top": "返回顶部",
"filters": "筛选器",
"firmware-files-count": "{count} 个文件",
"firmware-selected-count": "已选择 {count} 个",
diff --git a/frontend/src/locales/zh_TW/gallery.json b/frontend/src/locales/zh_TW/gallery.json
index 20567ac18..ced139e41 100644
--- a/frontend/src/locales/zh_TW/gallery.json
+++ b/frontend/src/locales/zh_TW/gallery.json
@@ -1,5 +1,6 @@
{
"all-loaded": "所有遊戲已載入",
+ "back-to-top": "回到頂端",
"filters": "篩選器",
"firmware-files-count": "{count} 個檔案",
"firmware-selected-count": "已選擇 {count} 個",
diff --git a/frontend/src/v2/components/AppShell/AppNav.vue b/frontend/src/v2/components/AppShell/AppNav.vue
index 3d80662f9..8a9022872 100644
--- a/frontend/src/v2/components/AppShell/AppNav.vue
+++ b/frontend/src/v2/components/AppShell/AppNav.vue
@@ -111,7 +111,8 @@ onBeforeUnmount(() => {
position: fixed;
top: 0;
left: 0;
- right: 0;
+ /* Clears a gallery scroller's scrollbar, which runs up under the bar. */
+ right: var(--r-v2-shell-scrollbar-w, 0px);
z-index: 100;
height: var(--r-nav-h);
background: transparent;
diff --git a/frontend/src/v2/components/Gallery/BackToTopButton.test.ts b/frontend/src/v2/components/Gallery/BackToTopButton.test.ts
new file mode 100644
index 000000000..8cd5e0ac8
--- /dev/null
+++ b/frontend/src/v2/components/Gallery/BackToTopButton.test.ts
@@ -0,0 +1,89 @@
+import { mount } from "@vue/test-utils";
+import { afterEach, describe, expect, it, vi } from "vitest";
+import BackToTopButton from "./BackToTopButton.vue";
+
+vi.mock("vue-i18n", () => ({
+ useI18n: () => ({ t: (key: string) => key }),
+}));
+
+const reducedMotion = { value: false };
+vi.mock("@/v2/composables/useReducedMotion", () => ({
+ useReducedMotion: () => ({ enabled: reducedMotion }),
+}));
+
+function makeScroller(clientHeight = 800) {
+ const el = document.createElement("div");
+ Object.defineProperty(el, "clientHeight", { value: clientHeight });
+ el.scrollTo = vi.fn() as typeof el.scrollTo;
+ const first = document.createElement("button");
+ first.className = "first";
+ el.appendChild(first);
+ document.body.appendChild(el);
+ return el;
+}
+
+function mountButton(scroller: HTMLElement, scrollTop: number) {
+ return mount(BackToTopButton, {
+ attachTo: document.body,
+ props: { scroller, scrollTop },
+ global: { stubs: { transition: false } },
+ });
+}
+
+afterEach(() => {
+ document.body.innerHTML = "";
+ reducedMotion.value = false;
+});
+
+describe("BackToTopButton", () => {
+ it("stays hidden within the first viewport", () => {
+ const wrapper = mountButton(makeScroller(), 400);
+ expect(wrapper.find("button").exists()).toBe(false);
+ });
+
+ it("shows once scrolled past a viewport", async () => {
+ const wrapper = mountButton(makeScroller(), 400);
+ await wrapper.setProps({ scrollTop: 1200 });
+ expect(wrapper.get("button").attributes("aria-label")).toBe(
+ "gallery.back-to-top",
+ );
+ });
+
+ it("smooth-scrolls the scroller to the top and emits", async () => {
+ const scroller = makeScroller();
+ const wrapper = mountButton(scroller, 1200);
+ await wrapper.get("button").trigger("click");
+ expect(scroller.scrollTo).toHaveBeenCalledWith({
+ top: 0,
+ behavior: "smooth",
+ });
+ expect(wrapper.emitted("scroll-to-top")).toHaveLength(1);
+ });
+
+ it("jumps without animation under reduced motion", async () => {
+ reducedMotion.value = true;
+ const scroller = makeScroller();
+ const wrapper = mountButton(scroller, 1200);
+ await wrapper.get("button").trigger("click");
+ expect(scroller.scrollTo).toHaveBeenCalledWith({
+ top: 0,
+ behavior: "auto",
+ });
+ });
+
+ it("hands keyboard focus to the first control at the top", async () => {
+ const scroller = makeScroller();
+ const wrapper = mountButton(scroller, 1200);
+ const btn = wrapper.get("button");
+ (btn.element as HTMLElement).focus();
+ await btn.trigger("click");
+ expect(document.activeElement).toBe(scroller.querySelector(".first"));
+ });
+
+ it("leaves focus alone on a pointer click", async () => {
+ const scroller = makeScroller();
+ const wrapper = mountButton(scroller, 1200);
+ await wrapper.get("button").trigger("click");
+ expect(document.activeElement).not.toBe(scroller.querySelector(".first"));
+ });
+});
diff --git a/frontend/src/v2/components/Gallery/BackToTopButton.vue b/frontend/src/v2/components/Gallery/BackToTopButton.vue
new file mode 100644
index 000000000..67c64f877
--- /dev/null
+++ b/frontend/src/v2/components/Gallery/BackToTopButton.vue
@@ -0,0 +1,82 @@
+
+
+
+
+
+
+
+
+
diff --git a/frontend/src/v2/components/Gallery/GalleryShell.vue b/frontend/src/v2/components/Gallery/GalleryShell.vue
index d7997da36..8011c8017 100644
--- a/frontend/src/v2/components/Gallery/GalleryShell.vue
+++ b/frontend/src/v2/components/Gallery/GalleryShell.vue
@@ -25,7 +25,7 @@ import {
RLetterHeading,
RVirtualScroller,
} from "@v2/lib";
-import { useIntersectionObserver } from "@vueuse/core";
+import { useIntersectionObserver, useResizeObserver } from "@vueuse/core";
import { storeToRefs } from "pinia";
import {
computed,
@@ -42,6 +42,7 @@ import { useUISettings } from "@/composables/useUISettings";
import storeGalleryFilter from "@/stores/galleryFilter";
import AlphaJumpMenu from "@/v2/components/Gallery/AlphaJumpMenu.vue";
import AlphaStrip from "@/v2/components/Gallery/AlphaStrip.vue";
+import BackToTopButton from "@/v2/components/Gallery/BackToTopButton.vue";
import FilterDrawer from "@/v2/components/Gallery/FilterDrawer.vue";
import GalleryToolbar from "@/v2/components/Gallery/GalleryToolbar.vue";
import GameListHeader from "@/v2/components/Gallery/GameListHeader.vue";
@@ -318,6 +319,9 @@ const jumpMenuVisible = computed(
// The strip's footprint: its letter column plus `--r-alpha-strip-gap`.
const STRIP_INSET_PX =
parseInt(layoutTokens.alphaStripWidth, 10) + parseInt(space[3], 10);
+// The scroller's classic scrollbar gutter (0 for overlay scrollbars), which
+// the rows and the strip both have to clear.
+const scrollbarWidth = ref(0);
// Card-art width reference (matches GameCard's `--r-card-art-w`); sets the
// fixed card HEIGHT (a 2/3 cover at this width). Real width follows the ratio.
const CARD_GAP_PX = 12;
@@ -328,7 +332,8 @@ const { columns, usableWidth } = useResponsiveColumns(sectionEl, {
gap: CARD_GAP_PX,
inset: () =>
(xs.value ? 28 : smAndDown.value ? 40 : 72) +
- (stripVisible.value ? STRIP_INSET_PX : 0),
+ (stripVisible.value ? STRIP_INSET_PX : 0) +
+ scrollbarWidth.value,
});
// Fallback cover ratio (boxart style) — the per-card `--r-cover-ratio` seed
@@ -427,6 +432,20 @@ const { virtualItems, letterToIndex, availableLetters, getItemHeight } =
});
const scrollerRef = ref | null>(null);
+const scrollerEl = computed(() => scrollerRef.value?.containerEl ?? null);
+useResizeObserver(scrollerEl, () => {
+ const el = scrollerEl.value;
+ if (el) scrollbarWidth.value = el.offsetWidth - el.clientWidth;
+});
+// Published on so the fixed top bar can stop short of the scrollbar,
+// which it would otherwise cover.
+const SCROLLBAR_W_VAR = "--r-v2-shell-scrollbar-w";
+watch(scrollbarWidth, (w) => {
+ document.documentElement.style.setProperty(SCROLLBAR_W_VAR, `${w}px`);
+});
+onBeforeUnmount(() => {
+ document.documentElement.style.removeProperty(SCROLLBAR_W_VAR);
+});
// Where the open row sits in the packed list. Recomputed when a row opens or
// the list re-packs, never on the animation's frames.
@@ -940,7 +959,7 @@ defineExpose({
:min-content-width="
layout === 'list' && !smAndDown ? listMinWidth : undefined
"
- class="r-v2-shell__scroller r-v2-scroll-hidden"
+ class="r-v2-shell__scroller"
:tabindex="-1"
@wheel.passive="endLetterJump"
@pointerdown.passive="endLetterJump"
@@ -1115,6 +1134,14 @@ defineExpose({
@pick="scrollToLetter"
/>
+
+
@@ -1240,6 +1267,9 @@ html[data-bp~="md-and-up"] .r-v2-shell__list-header {
flex: 1;
height: 100%;
scroll-timeline: --r-v2-shell-scroll block;
+ /* A stable gutter keeps the row packing from shifting when the content
+ starts or stops overflowing. */
+ scrollbar-gutter: stable;
padding: 0 calc(var(--r-row-pad) + var(--r-v2-shell-strip)) 60px
var(--r-row-pad);
}
@@ -1326,7 +1356,7 @@ html[data-bp~="md-and-up"] .r-v2-shell__list-header {
.r-v2-shell .r-v2-shell__strip {
position: absolute;
top: calc(var(--r-nav-h) + var(--r-v2-shell-toolbar-h));
- right: 0;
+ right: var(--r-v2-shell-scrollbar-w, 0px);
bottom: 0;
z-index: 5;
justify-content: flex-start;
@@ -1377,9 +1407,26 @@ html[data-bp~="md-and-up"] .r-v2-shell__list-header {
}
}
+/* Bottom corner of the rows' column, clear of the strip and the scrollbar. */
+.r-v2-shell__back-to-top {
+ position: absolute;
+ right: calc(
+ var(--r-row-pad) + var(--r-v2-shell-strip) +
+ var(--r-v2-shell-scrollbar-w, 0px)
+ );
+ bottom: var(--r-space-6);
+ z-index: 6;
+}
+html[data-bp~="sm-and-down"] .r-v2-shell__back-to-top {
+ bottom: calc(
+ var(--r-bottom-nav-h) + env(safe-area-inset-bottom) + var(--r-space-4)
+ );
+}
+
/* The section runs under the top bar; keep the floating dock below it. */
.r-v2-shell .r-v2-shell__floating {
top: calc(var(--r-nav-h) + 14px);
+ margin-right: var(--r-v2-shell-scrollbar-w, 0px);
}
/* Smaller cards on phones. Matches GameCard's own xs `--r-card-art-w` so