Skip to content

Commit ba838f7

Browse files
juliusmarmingecodex
andcommitted
fix(web): reserve highlighted folder action space
Co-authored-by: codex <[email protected]>
1 parent 3b87ab8 commit ba838f7

3 files changed

Lines changed: 48 additions & 3 deletions

File tree

‎apps/web/src/components/CommandPalette.logic.test.ts‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { describe, expect, it, vi } from "vite-plus/test";
22
import { EnvironmentId, ProjectId, ProviderInstanceId, ThreadId } from "@t3tools/contracts";
33
import type { Thread } from "../types";
44
import {
5+
browseInputEndPaddingClass,
56
buildBrowseGroups,
67
buildThreadActionItems,
78
enumerateCommandPaletteItems,
@@ -10,6 +11,35 @@ import {
1011
type CommandPaletteGroup,
1112
} from "./CommandPalette.logic";
1213

14+
describe("browseInputEndPaddingClass", () => {
15+
it("reserves the widest space for the create action", () => {
16+
expect(
17+
browseInputEndPaddingClass({
18+
willCreateProjectPath: true,
19+
hasHighlightedBrowseItem: false,
20+
}),
21+
).toContain("pe-38");
22+
});
23+
24+
it("reserves space for the wider highlighted-item shortcut", () => {
25+
expect(
26+
browseInputEndPaddingClass({
27+
willCreateProjectPath: false,
28+
hasHighlightedBrowseItem: true,
29+
}),
30+
).toContain("pe-30");
31+
});
32+
33+
it("keeps the compact reserve for the normal add action", () => {
34+
expect(
35+
browseInputEndPaddingClass({
36+
willCreateProjectPath: false,
37+
hasHighlightedBrowseItem: false,
38+
}),
39+
).toContain("pe-24");
40+
});
41+
});
42+
1343
describe("reduceCommandPaletteUiState", () => {
1444
const closedState = { open: false, mode: "command", openIntent: null } as const;
1545

‎apps/web/src/components/CommandPalette.logic.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ export const RECENT_THREAD_LIMIT = 12;
1515
export const ITEM_ICON_CLASS = "size-4 text-icon-muted";
1616
export const ADDON_ICON_CLASS = "size-4";
1717

18+
export function browseInputEndPaddingClass(input: {
19+
readonly willCreateProjectPath: boolean;
20+
readonly hasHighlightedBrowseItem: boolean;
21+
}): string {
22+
if (input.willCreateProjectPath) {
23+
return "*:data-[slot=autocomplete-input]:pe-38!";
24+
}
25+
if (input.hasHighlightedBrowseItem) {
26+
return "*:data-[slot=autocomplete-input]:pe-30!";
27+
}
28+
return "*:data-[slot=autocomplete-input]:pe-24!";
29+
}
30+
1831
/**
1932
* The global search overlay hosts three mutually exclusive surfaces: the
2033
* command palette (⌘K), the project file picker (⌘P), and project content

‎apps/web/src/components/CommandPalette.tsx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ import {
9898
} from "../wslPaths";
9999
import {
100100
ADDON_ICON_CLASS,
101+
browseInputEndPaddingClass,
101102
buildBrowseGroups,
102103
buildProjectActionItems,
103104
buildRootGroups,
@@ -2351,9 +2352,10 @@ function OpenCommandPaletteDialog(props: {
23512352
addProjectCloneFlow?.step === "repository"
23522353
? "*:data-[slot=autocomplete-input]:pe-32!"
23532354
: isBrowsing
2354-
? willCreateProjectPath
2355-
? "*:data-[slot=autocomplete-input]:pe-38!"
2356-
: "*:data-[slot=autocomplete-input]:pe-24!"
2355+
? browseInputEndPaddingClass({
2356+
willCreateProjectPath,
2357+
hasHighlightedBrowseItem,
2358+
})
23572359
: undefined,
23582360
placeholder: inputPlaceholder,
23592361
wrapperClassName: isSubmenu

0 commit comments

Comments
 (0)