diff --git a/e2e/notificationSettingsLayout.spec.ts b/e2e/notificationSettingsLayout.spec.ts new file mode 100644 index 000000000..e6c0136d8 --- /dev/null +++ b/e2e/notificationSettingsLayout.spec.ts @@ -0,0 +1,73 @@ +import { expect, test } from "./fixtures"; + +test.beforeEach(async ({ workbench: page }) => { + await page.keyboard.press("Meta+,"); + const dialog = page.getByRole("dialog", { name: "Settings", exact: true }); + await dialog.getByRole("textbox", { name: "Search settings" }).fill("Notifications"); + await dialog.getByRole("treeitem", { name: "Notifications", exact: true }).click(); +}); + +test("notification group controls stay inside narrow settings", async ({ workbench: page }) => { + await page.setViewportSize({ width: 520, height: 760 }); + const groups = page.getByRole("region", { name: "Groups", exact: true }); + const popup = groups.getByRole("button", { name: "System Messages popup type" }); + await expect(popup).toBeInViewport({ ratio: 0.98 }); + expect(await groups.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1); + + const list = groups.getByRole("listbox", { name: "Notification groups" }); + const controls = groups.getByRole("region", { name: "System Messages", exact: true }); + const listBounds = (await list.boundingBox())!; + expect((await controls.boundingBox())!.y).toBeGreaterThanOrEqual(listBounds.y + listBounds.height); + await popup.click(); + await expect(page.getByRole("option", { name: "Sticky balloon", exact: true })).toBeInViewport(); + await page.keyboard.press("Escape"); + + await list.press("End"); + const lastGroup = list.getByRole("option", { name: "Distraction Free Mode", exact: true }); + await expect(lastGroup).toHaveAttribute("aria-selected", "true"); + await expect(lastGroup).toBeInViewport({ ratio: 0.98 }); + await list.press("Home"); + + await page.setViewportSize({ width: 1100, height: 760 }); + const wideList = (await list.boundingBox())!; + const wideControls = (await controls.boundingBox())!; + expect(wideControls.x).toBeGreaterThan(wideList.x + wideList.width); + expect(wideControls.y).toBeLessThan(wideList.y + wideList.height); +}); + +test("notification groups follow settings search and keep edits per group", async ({ workbench: page }) => { + const dialog = page.getByRole("dialog", { name: "Settings", exact: true }); + const search = dialog.getByRole("textbox", { name: "Search settings" }); + const list = dialog.getByRole("listbox", { name: "Notification groups" }); + const systemPopup = dialog.getByRole("button", { name: "System Messages popup type" }); + const versionControlPopup = dialog.getByRole("button", { name: "Version Control popup type" }); + const versionControlLog = dialog.getByRole("checkbox", { name: "Show Version Control in tool window" }); + + await list.press("ArrowDown"); + await expect(list.getByRole("option", { name: "Language Servers" })).toHaveAttribute("aria-selected", "true"); + await search.fill("Version Control"); + await dialog.getByRole("treeitem", { name: "Notifications", exact: true }).click(); + await expect(list.getByRole("option", { name: "Version Control", exact: true })).toHaveAttribute( + "aria-selected", + "true", + ); + await versionControlPopup.click(); + await page.getByRole("option", { name: "No popup", exact: true }).click(); + await versionControlLog.uncheck(); + + await list.press("Home"); + await expect(systemPopup).toHaveText("Balloon"); + await expect(dialog.getByRole("checkbox", { name: "Show System Messages in tool window" })).toBeChecked(); + await list.getByRole("option", { name: "Version Control", exact: true }).click(); + await expect(versionControlPopup).toHaveText("No popup"); + await expect(versionControlLog).not.toBeChecked(); + + await dialog.getByRole("button", { name: "Apply", exact: true }).click(); + await expect(dialog.getByRole("button", { name: "Apply", exact: true })).toBeDisabled(); + await dialog.getByRole("button", { name: "Cancel", exact: true }).click(); + await page.keyboard.press("Meta+,"); + await search.fill("Version Control"); + await dialog.getByRole("treeitem", { name: "Notifications", exact: true }).click(); + await expect(versionControlPopup).toHaveText("No popup"); + await expect(versionControlLog).not.toBeChecked(); +}); diff --git a/src/features/settings/pages/Behavior.module.css b/src/features/settings/pages/Behavior.module.css index ac47df70a..abb4fe4de 100644 --- a/src/features/settings/pages/Behavior.module.css +++ b/src/features/settings/pages/Behavior.module.css @@ -132,29 +132,53 @@ accent-color: var(--accent); } -.table { - width: 100%; - border-collapse: collapse; +.notificationGroups { + display: grid; + grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); + align-items: start; + gap: var(--space-4); } -.table th { - white-space: nowrap; - text-align: left; - font-weight: normal; - color: var(--fg-muted); - height: var(--h-list-row); - padding: 0 8px; - border-bottom: 1px solid var(--border); +.notificationList { + height: calc(10 * var(--h-list-row) + 2px); + min-width: 0; + border: 1px solid var(--border-strong); + border-radius: var(--radius-small); } -.table td { - white-space: nowrap; - height: 32px; - padding: 0 8px; +.notificationGroupLabel { + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; } -.table tbody tr:hover { - background: var(--bg-tree-hover); +.notificationDetails { + display: flex; + flex-direction: column; + align-items: flex-start; + min-width: 0; + gap: var(--space-2); } -.center { - text-align: center; +.notificationTitle { + margin: 0; + color: var(--fg-strong); + font-size: var(--fs-ui); + font-weight: 600; + overflow-wrap: anywhere; +} +.notificationDetails .notificationPopupRow { + grid-template-columns: fit-content(42%) minmax(0, 1fr); + align-self: stretch; + padding-inline: 0; + margin-inline: 0; +} +.notificationPopupRow label { + white-space: normal; +} +@container settings-content (max-width: 440px) { + .notificationGroups { + grid-template-columns: minmax(0, 1fr); + } + .notificationList { + height: calc(5 * var(--h-list-row) + 2px); + } } .iconPacks { diff --git a/src/features/settings/pages/behavior.tsx b/src/features/settings/pages/behavior.tsx index 25cb43091..a333a7640 100644 --- a/src/features/settings/pages/behavior.tsx +++ b/src/features/settings/pages/behavior.tsx @@ -16,10 +16,10 @@ import { notifications } from "@/workbench/contributions"; import { ZOOM_LIMITS } from "@/platform/zoom"; import { SCHEMES as EDITOR_SCHEMES, listSchemes, customSchemes } from "@/platform/colorScheme"; import { formatTimestamp } from "@/platform/dateFormat"; -import { Button, Checkbox, IconButton, Input, Popup, type SelectOption, T } from "@/ui"; +import { Button, Checkbox, IconButton, Input, List, Popup, type SelectOption, T } from "@/ui"; import { NOTIFICATION_GROUPS } from "@/workbench/notificationStore"; import { ColorSwatches, FormGroup, NumberInput, Row, SearchLabel, Select, Toggle } from "../components/Form"; -import { useLabelMatch, useSetting } from "../components/context"; +import { useLabelMatch, useSearchQuery, useSetting } from "../components/context"; import { IDLE_LIMITS, type Antialiasing, @@ -36,6 +36,7 @@ import { type PresentationAssistantPosition, type PresentationAssistantSize, } from "../model/behaviorSchema"; +import { labelMatches } from "../model/pages"; import { ACCENT_PRESETS, LIMITS, type ThemeId } from "../model/schema"; import type { PageSpec } from "./spec"; import { HTTP_PROXY_PAGE } from "./httpProxy"; @@ -825,59 +826,57 @@ const DISPLAY_OPTIONS: SelectOption[] = [ { value: "none", label: "No popup" }, ]; -function NotificationGroupsTable() { +function NotificationGroups() { const [groups, setGroups] = useSetting>("notifications.groups"); - const update = (id: string, patch: Partial) => { - const next = { ...(groups[id] ?? { display: "balloon", log: true }), ...patch }; + const query = useSearchQuery(); + const [selection, setSelection] = useState({ query: "", index: 0 }); + const matched = NOTIFICATION_GROUPS.findIndex((group) => labelMatches(group.title, query)); + const index = matched >= 0 && query !== selection.query ? matched : selection.index; + const { id, title } = NOTIFICATION_GROUPS[index]!; + const value = groups[id] ?? { display: "balloon", log: true }; + const update = (patch: Partial) => { + const next = { ...value, ...patch }; const all = { ...groups }; - // Defaults are not stored. if (next.display === "balloon" && next.log) delete all[id]; else all[id] = next; setGroups(all); }; + return ( - - - - - - - - - - {NOTIFICATION_GROUPS.map((g) => { - const v = groups[g.id] ?? { display: "balloon", log: true }; - return ( - - - - - - ); - })} - -
- Group - - Popup type - - Show in tool window -
- - - - value={v.display} - options={DISPLAY_OPTIONS} - onChange={(display) => update(g.id, { display })} - aria-label={tx`${g.title} popup type`} - /> - - update(g.id, { log })} - aria-label={tx`Show ${g.title} in tool window`} - /> -
+
+ group.id} + activeIndex={index} + onActiveChange={(index) => setSelection({ query, index })} + renderItem={(group) => ( + + + + )} + /> +
+

+ +

+ + + value={value.display} + options={DISPLAY_OPTIONS} + onChange={(display) => update({ display })} + aria-label={tx`${title} popup type`} + /> + + update({ log })} + label={} + aria-label={tx`Show ${title} in tool window`} + /> +
+
); } @@ -1211,6 +1210,17 @@ export const BEHAVIOR_PAGES: PageSpec[] = [ }, ], }, + { + title: "Groups", + options: [ + { + kind: "custom", + label: "Popup type", + keywords: [...NOTIFICATION_GROUPS.map((g) => g.title), "Sticky balloon", "No popup", "Show in tool window"], + component: NotificationGroups, + }, + ], + }, { title: "Terminal", options: [ @@ -1236,17 +1246,6 @@ export const BEHAVIOR_PAGES: PageSpec[] = [ }, ], }, - { - title: "Groups", - options: [ - { - kind: "custom", - label: "Popup type", - keywords: [...NOTIFICATION_GROUPS.map((g) => g.title), "Sticky balloon", "No popup", "Show in tool window"], - component: NotificationGroupsTable, - }, - ], - }, ], }, ];