@devries-cameron20 / t3code-1 / commits / a23085273f
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): adding the last snooze option no longer reorders rows mid-edit (#33279)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

benoneill66 committed Nov 21, 2026 at 00:20 UTC a23085273f68b2167dc3bce0e0e406852726b45a
2 files changed +63 -2
apps/web/src/components/settings/SnoozePresetsSettings.browser.test.tsx new
+60
@@ -0,0 +1,60 @@
1 +import { render } from "../../../test/render";
2 +import {
3 + DEFAULT_SNOOZE_PRESETS,
4 + DEFAULT_UNIFIED_SETTINGS,
5 + MAX_SNOOZE_PRESETS,
6 + type SnoozePresetSetting,
7 +} from "@t3tools/contracts/settings";
8 +import { describe, expect, it, vi } from "vite-plus/test";
9 +import { page, userEvent } from "vite-plus/test/browser";
10 +
11 +import "../../index.css";
12 +import type { ScopedSettingsPatch } from "./scopedSettings";
13 +
14 +const state = vi.hoisted(() => ({
15 + presets: [] as ReadonlyArray<SnoozePresetSetting>,
16 + updateSettings: vi.fn<(patch: ScopedSettingsPatch) => void>(),
17 +}));
18 +
19 +vi.mock(import("./useScopedSettings"), async (original) => ({
20 + ...(await original()),
21 + useScopedSettings: (() => ({
22 + ...DEFAULT_UNIFIED_SETTINGS,
23 + snoozePresets: state.presets,
24 + })) as never,
25 + useScopedSettingsMixed: () => false,
26 + useUpdateScopedSettings: () => state.updateSettings,
27 +}));
28 +vi.mock(import("./settingsLayout"), async (original) => ({
29 + ...(await original()),
30 + SettingsRow: ({ children }) => <div>{children}</div>,
31 +}));
32 +
33 +import { SnoozePresetsRow } from "./SnoozePresetsSettings";
34 +
35 +describe("SnoozePresetsRow", () => {
36 + it("keeps the option that fills the list at the bottom until focus leaves", async () => {
37 + // One short of the limit; the next option offered is "In 30 minutes", which sorts first.
38 + state.presets = [
39 + ...DEFAULT_SNOOZE_PRESETS,
40 + { kind: "at", day: "saturday", time: "09:00" },
41 + { kind: "after", minutes: 24 * 60 },
42 + ];
43 + expect(state.presets).toHaveLength(MAX_SNOOZE_PRESETS - 1);
44 + // The row reads no route state.
45 + await using screen = await render(<SnoozePresetsRow />, { router: false });
46 + state.updateSettings.mockReset().mockImplementation((patch) => {
47 + state.presets = patch.snoozePresets ?? state.presets;
48 + void screen.rerender(<SnoozePresetsRow />);
49 + });
50 +
51 + const add = page.getByRole("button", { name: "Add option" });
52 + await userEvent.click(add);
53 +
54 + // A disabled button drops focus, which the list reads as leaving it and sorts mid-edit.
55 + await expect.element(add).toHaveFocus();
56 + await expect.element(add).toHaveAttribute("aria-disabled", "true");
57 + const added = page.getByRole("group", { name: `Snooze option ${MAX_SNOOZE_PRESETS}` });
58 + await expect.element(added.getByRole("textbox", { name: "Amount" })).toHaveValue("30");
59 + });
60 +});
apps/web/src/components/settings/SnoozePresetsSettings.tsx
+3 -2
@@ -334,8 +334,9 @@ function SnoozePresetList(props: {
334 <Button
335 variant="ghost-muted"
336 size="compact"
337 - disabled={props.presets.length >= MAX_SNOOZE_PRESETS}
338 - onClick={props.onAdd}
337 + // Not `disabled`: that drops focus, which the list would read as leaving it and sort.
338 + aria-disabled={props.presets.length >= MAX_SNOOZE_PRESETS || undefined}
339 + onClick={props.presets.length >= MAX_SNOOZE_PRESETS ? undefined : props.onAdd}
340 >
341 <PlusIcon />
342 <T>Add option</T>