From 474844f9615a9dde6b5369eb61463f5c30f93dfc Mon Sep 17 00:00:00 2001 From: James Babcock Date: Sat, 1 Aug 2026 16:23:52 -0700 Subject: [PATCH] App-launcher UI: Wrapping, fix a minor folder-selection UI bug --- app/ui/apps/file-browser.ts | 19 +++++++++++++++++-- app/ui/shell/launcher-app.ts | 31 +++++++++++++++++-------------- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/app/ui/apps/file-browser.ts b/app/ui/apps/file-browser.ts index 846ea36b..c605178b 100644 --- a/app/ui/apps/file-browser.ts +++ b/app/ui/apps/file-browser.ts @@ -272,8 +272,23 @@ export class FileBrowserLayer implements Layer { case "scroll-up": case "scroll-down": { const delta = event.type === "scroll-down" ? 1 : -1; - if (this.iconMode === "item" && row?.kind === "grid") { - this.selectedCol = clamp(this.selectedCol + delta, 0, row.items.length - 1); + if (this.iconMode === "item") { + // Item selection traverses linearly: past a row's edge it continues + // onto the adjacent row (a special row counts as a single item). + if (row?.kind === "grid") { + const next = clamp(this.selectedCol, 0, row.items.length - 1) + delta; + if (next >= 0 && next < row.items.length) { + this.selectedCol = next; + return; + } + } + const adjacentIndex = this.selectedRow + delta; + if (adjacentIndex < 0 || adjacentIndex >= iconRows.length) return; + this.selectedRow = adjacentIndex; + const adjacent = iconRows[adjacentIndex]!; + if (adjacent.kind === "grid") { + this.selectedCol = delta > 0 ? 0 : adjacent.items.length - 1; + } } else { this.selectedRow = clamp(this.selectedRow + delta, 0, Math.max(0, iconRows.length - 1)); } diff --git a/app/ui/shell/launcher-app.ts b/app/ui/shell/launcher-app.ts index 52a3c430..3e8eb0e1 100644 --- a/app/ui/shell/launcher-app.ts +++ b/app/ui/shell/launcher-app.ts @@ -72,7 +72,6 @@ class LauncherGridLayer implements Layer { private selectedRow = 0; private selectedCol = 1; private scrollRow = 0; - private wasFocused = false; /** Folder whose contents the grid is showing, or null for the top grid. */ private currentFolder: string | null = null; @@ -135,14 +134,6 @@ class LauncherGridLayer implements Layer { const { width, height } = ctx.stack.getBaseSize(); const image = new GrayImage(width, height, 0); const focused = ctx.stack.isFocused(); - // Re-entering the launcher (focus gained) resets to the top grid's row - // selection, so the view never resumes inside a stale folder. - if (focused && !this.wasFocused) { - this.mode = "row"; - this.currentFolder = null; - } - this.wasFocused = focused; - const entries = this.entries(); const rows = this.rowCount(entries.length); this.selectedRow = clamp(this.selectedRow, 0, rows - 1); @@ -216,11 +207,19 @@ class LauncherGridLayer implements Layer { if (this.mode === "row") { this.selectedRow = clamp(this.selectedRow + delta, 0, rows - 1); } else { - this.selectedCol = clamp( - this.selectedCol + delta, - 0, - Math.max(0, this.itemsInRow(entries.length, this.selectedRow) - 1), - ); + // Item selection traverses the grid linearly: past a row's edge it + // continues onto the adjacent row (stopping at the grid's ends). + const itemCount = this.itemsInRow(entries.length, this.selectedRow); + const next = clamp(this.selectedCol, 0, itemCount - 1) + delta; + if (next >= 0 && next < itemCount) { + this.selectedCol = next; + } else if (next < 0 && this.selectedRow > 0) { + this.selectedRow--; + this.selectedCol = this.itemsInRow(entries.length, this.selectedRow) - 1; + } else if (next >= itemCount && this.selectedRow < rows - 1) { + this.selectedRow++; + this.selectedCol = 0; + } } return; } @@ -241,6 +240,10 @@ class LauncherGridLayer implements Layer { this.selectedRow = 0; this.scrollRow = 0; } else { + // Return to the top grid before launching, so the launcher never + // shows (even briefly) stale folder contents when re-entered. + if (this.currentFolder !== null) this.exitFolder(); + this.mode = "row"; await this.options.launchApp(entry.appId); } }