Skip to content

Commit f6e3879

Browse files
fix(ui): align Communications settings layout (#131421)
* fix(ui): align Communications header and tabs * fix(ui): remove Communications section help * fix(ui): refine settings tab and advanced spacing * fix(ui): narrow tab and disclosure event targets * fix(ui): preserve advanced menu labels
1 parent b9c955c commit f6e3879

20 files changed

Lines changed: 399 additions & 211 deletions

‎config/assertion-safety-baseline.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3975,7 +3975,7 @@ ui/src/components/exec-approval.ts 1
39753975
ui/src/components/file-preview-modal.ts 1
39763976
ui/src/components/github-link-hovercard-registration.ts 1
39773977
ui/src/components/github-link-hovercard.runtime.ts 2
3978-
ui/src/components/hub-tabs.ts 2
3978+
ui/src/components/hub-tabs.ts 1
39793979
ui/src/components/input-dialog.ts 1
39803980
ui/src/components/lobster-dex.ts 2
39813981
ui/src/components/login-gate.ts 3

‎ui/src/components/config-form.browser.test.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,11 @@ describe("config form renderer", () => {
313313
container,
314314
);
315315

316-
const headings = Array.from(container.querySelectorAll(".settings-section__heading")).map(
317-
(node) => node.textContent?.trim(),
318-
);
316+
const headings = Array.from(
317+
container.querySelectorAll(
318+
".settings-section > .settings-section__header .settings-section__heading",
319+
),
320+
).map((node) => node.textContent?.trim());
319321
expect(headings).toEqual(["Auth"]);
320322
// The subsection object emits its fields directly; no nested details block
321323
// repeats the subsection title inside the group.

‎ui/src/components/config-form.render.ts‎

Lines changed: 33 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ type ConfigFormProps = {
2727
activeSubsection?: string | null;
2828
showAdvanced?: boolean;
2929
forceAdvancedSection?: string | null;
30-
/** Required: the collapsed-advanced ghost row's only action. Optional would
31-
* permit an inert "Show advanced" control that strands hidden settings. */
30+
/** Required: the collapsed advanced disclosure's only action. Optional would
31+
* permit an inert control that strands hidden settings. */
3232
onShowAdvanced: () => void;
3333
/** Paired expanded-state action. Omit when search or a forced route owns the reveal. */
3434
onHideAdvanced?: () => void;
3535
/** Inline actions rendered next to the active section heading (e.g. env peek). */
3636
sectionActions?: TemplateResult;
37+
showSectionDocs?: boolean;
3738
/** A Control UI-owned row rendered before common schema rows in the active section. */
3839
sectionPrelude?: TemplateResult;
3940
/** Composite pages render custom rows above the form; an empty schema
@@ -46,32 +47,15 @@ type ConfigFormProps = {
4647
onRemove?: (path: Array<string | number>) => void;
4748
};
4849

49-
function renderAdvancedDivider(onHideAdvanced: (() => void) | undefined) {
50-
return html`<div class="config-advanced-divider">
51-
<span>${t("configForm.advancedDivider")}</span>
52-
${onHideAdvanced
53-
? html`<button
54-
type="button"
55-
class="config-advanced-divider__toggle config-show-advanced active"
56-
aria-pressed="true"
57-
@click=${() => onHideAdvanced()}
58-
>
59-
${t("common.hideAdvanced")}
60-
</button>`
61-
: nothing}
62-
</div>`;
63-
}
64-
6550
/** Common/advanced split body shared by the config page and channel forms so
66-
* every schema surface hides advanced settings behind the same ghost row. */
51+
* every schema surface uses the same native disclosure. */
6752
export function renderConfigTierGroups(params: {
6853
schema: JsonSchema;
6954
path: Array<string | number>;
7055
hints: ConfigUiHints;
7156
revealAdvanced: boolean;
7257
onShowAdvanced: () => void;
73-
/** Surfaces with collapsible advanced fields pass this so the expanded
74-
* divider remains the single inverse of the collapsed ghost action. */
58+
/** Surfaces with collapsible advanced fields pass this as the inverse action. */
7559
onHideAdvanced?: () => void;
7660
renderTier: (node: JsonSchema) => TemplateResult | typeof nothing;
7761
commonPrelude?: TemplateResult;
@@ -81,9 +65,6 @@ export function renderConfigTierGroups(params: {
8165
path: params.path.map(String),
8266
hints: params.hints,
8367
});
84-
// An advanced-only schema needs no separator, but a surface whose only
85-
// collapse control lives on the divider would otherwise strand the tier open.
86-
const showDivider = Boolean(split.common) || Boolean(params.onHideAdvanced);
8768
// The wrapper owns tier spacing so embedders without a settings-section
8869
// parent (the channel forms) do not render the tiers flush against each other.
8970
return html`
@@ -96,29 +77,33 @@ export function renderConfigTierGroups(params: {
9677
</div>`
9778
: nothing}
9879
${split.advanced && split.advancedLeafCount > 0
99-
? params.revealAdvanced
100-
? html`
101-
${showDivider ? renderAdvancedDivider(params.onHideAdvanced) : nothing}
102-
<div class="settings-group">${params.renderTier(split.advanced)}</div>
103-
`
104-
: html`
105-
<button
106-
type="button"
107-
class="config-advanced-ghost config-show-advanced"
108-
aria-pressed="false"
109-
@click=${() => params.onShowAdvanced()}
110-
>
111-
<span class="config-advanced-ghost__count">
112-
${t(
113-
split.advancedLeafCount === 1
114-
? "configForm.advancedHidden"
115-
: "configForm.advancedHiddenPlural",
116-
{ count: String(split.advancedLeafCount) },
117-
)}
118-
</span>
119-
<span class="config-advanced-ghost__action">${t("configForm.showAdvanced")}</span>
120-
</button>
121-
`
80+
? html`<details
81+
class="config-advanced-disclosure"
82+
?open=${params.revealAdvanced}
83+
@toggle=${(event: Event) => {
84+
const disclosure = event.currentTarget;
85+
if (!(disclosure instanceof HTMLDetailsElement)) {
86+
return;
87+
}
88+
if (disclosure.open === params.revealAdvanced) {
89+
return;
90+
}
91+
if (disclosure.open) {
92+
params.onShowAdvanced();
93+
} else if (params.onHideAdvanced) {
94+
params.onHideAdvanced();
95+
} else {
96+
disclosure.open = true;
97+
}
98+
}}
99+
>
100+
<summary class="settings-section__heading config-advanced-disclosure__summary">
101+
${t("configForm.advancedSettings")}
102+
</summary>
103+
${params.revealAdvanced
104+
? html`<div class="settings-group">${params.renderTier(split.advanced)}</div>`
105+
: nothing}
106+
</details>`
122107
: nothing}
123108
</div>
124109
`;
@@ -227,7 +212,7 @@ export function renderConfigForm(props: ConfigFormProps) {
227212
path: Array<string | number>;
228213
}) => {
229214
const sectionHint = hintForPath(params.path.slice(0, 1), props.uiHints);
230-
const docsUrl = sectionHint?.docsUrl;
215+
const docsUrl = props.showSectionDocs === false ? undefined : sectionHint?.docsUrl;
231216
const docsTriggerId = `settings-section-help-${params.id}`;
232217
const revealAdvanced =
233218
props.showAdvanced === true ||

‎ui/src/components/hub-tabs.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ describe("renderHubTabs", () => {
5959

6060
it("selects only enabled tabs from direct user activation", () => {
6161
const onSelect = vi.fn();
62+
const onActivate = vi.fn();
6263
const container = document.createElement("div");
6364
render(
6465
renderHubTabs({
@@ -72,6 +73,7 @@ describe("renderHubTabs", () => {
7273
ariaLabel: "Example sections",
7374
panelId: "example-panel",
7475
onSelect,
76+
onActivate,
7577
}),
7678
container,
7779
);
@@ -92,6 +94,7 @@ describe("renderHubTabs", () => {
9294

9395
expect(onSelect).toHaveBeenCalledOnce();
9496
expect(onSelect).toHaveBeenCalledWith("second");
97+
expect(onActivate).toHaveBeenCalledWith(container.querySelector("#example-tab-second"));
9598
expect(container.querySelector("wa-tab-group")?.getAttribute("activation")).toBe("manual");
9699
});
97100

‎ui/src/components/hub-tabs.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type HubTabsProps<T extends string> = {
2121
className?: string;
2222
variant?: "primary" | "sub";
2323
onSelect: (tab: T) => void;
24+
onActivate?: (element: HTMLElement) => void;
2425
};
2526

2627
// Keyboard activation unmounts a route-owned strip, so the destination strip
@@ -89,15 +90,24 @@ export function renderHubTabs<T extends string>(props: HubTabsProps<T>): Templat
8990
aria-selected=${selected ? "true" : "false"}
9091
data-test-id=${tab.testId ?? nothing}
9192
@click=${(event: MouseEvent) => {
93+
const activeElement = event.currentTarget;
94+
if (!(activeElement instanceof HTMLElement)) {
95+
return;
96+
}
9297
if (
9398
!tab.disabled &&
9499
(event.detail > 0 || event.isTrusted) &&
95100
tab.value !== props.active
96101
) {
97102
props.onSelect(tab.value);
103+
props.onActivate?.(activeElement);
98104
}
99105
}}
100106
@keydown=${(event: KeyboardEvent) => {
107+
const activeElement = event.currentTarget;
108+
if (!(activeElement instanceof HTMLElement)) {
109+
return;
110+
}
101111
if (
102112
!tab.disabled &&
103113
!event.repeat &&
@@ -109,9 +119,10 @@ export function renderHubTabs<T extends string>(props: HubTabsProps<T>): Templat
109119
hubId: props.id,
110120
tab: tab.value,
111121
at: Date.now(),
112-
source: event.currentTarget as Element,
122+
source: activeElement,
113123
};
114124
props.onSelect(tab.value);
125+
props.onActivate?.(activeElement);
115126
}
116127
}}
117128
${selected ? ref((element) => reclaimFocus(props.id, tab.value, element)) : nothing}

‎ui/src/e2e/config-form-defaults.e2e.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ suite.define(() => {
135135
const enabledRow = settingsRow(page, "Enabled");
136136
const modeRow = settingsRow(page, "Mode");
137137
const payloadRow = settingsRow(page, "Payload");
138-
const profileBlock = panel.locator("details").filter({
138+
const profileBlock = panel.locator("details.cfg-object").filter({
139139
has: page.locator(".cfg-object__summary .settings-row__title").getByText("Profile", {
140140
exact: true,
141141
}),
@@ -215,7 +215,7 @@ suite.define(() => {
215215
const reloadedEnabledRow = settingsRow(page, "Enabled");
216216
const reloadedModeRow = settingsRow(page, "Mode");
217217
const reloadedPayloadRow = settingsRow(page, "Payload");
218-
const reloadedProfileBlock = reloadedPanel.locator("details").filter({
218+
const reloadedProfileBlock = reloadedPanel.locator("details.cfg-object").filter({
219219
has: page
220220
.locator(".cfg-object__summary .settings-row__title")
221221
.getByText("Profile", { exact: true }),

‎ui/src/e2e/config-form-guidance.e2e.test.ts‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,14 @@ suite.define(() => {
198198

199199
const response = await page.goto(`${suite.server.baseUrl}settings/appearance`);
200200
expect(response?.status()).toBe(200);
201-
await page.getByRole("radio", { name: "UI", exact: true }).click();
201+
await page.getByRole("tab", { name: "UI", exact: true }).click();
202202

203-
const disclosure = page.locator(".config-advanced-ghost");
203+
const disclosure = page.locator("details.config-advanced-disclosure");
204204
await expect.poll(() => disclosure.count()).toBe(1);
205-
await expect.poll(() => disclosure.textContent()).toContain("2 advanced settings hidden");
206-
await expect.poll(() => page.locator(".config-show-advanced").count()).toBe(1);
205+
await expect.poll(() => disclosure.getAttribute("open")).toBeNull();
206+
await expect
207+
.poll(() => disclosure.locator("summary").textContent())
208+
.toContain("Advanced settings");
207209
await expect
208210
.poll(() => page.getByText("Show Advanced Settings", { exact: true }).count())
209211
.toBe(0);
@@ -217,11 +219,8 @@ suite.define(() => {
217219
});
218220
}
219221

220-
await disclosure.click();
221-
const hideAdvanced = page.locator(".config-advanced-divider__toggle");
222-
await expect.poll(() => hideAdvanced.count()).toBe(1);
223-
await expect.poll(() => hideAdvanced.textContent()).toContain("Hide Advanced");
224-
await expect.poll(() => disclosure.count()).toBe(0);
222+
await disclosure.locator("summary").click();
223+
await expect.poll(() => disclosure.getAttribute("open")).not.toBeNull();
225224

226225
if (captureUiProofEnabled) {
227226
await page.screenshot({
@@ -231,8 +230,8 @@ suite.define(() => {
231230
});
232231
}
233232

234-
await hideAdvanced.click();
235-
await expect.poll(() => disclosure.count()).toBe(1);
233+
await disclosure.locator("summary").click();
234+
await expect.poll(() => disclosure.getAttribute("open")).toBeNull();
236235
await page.waitForTimeout(750);
237236
expect(await gateway.getRequests("config.patch")).toHaveLength(0);
238237
expect(await gateway.getRequests("config.set")).toHaveLength(0);
@@ -263,7 +262,7 @@ suite.define(() => {
263262

264263
const response = await page.goto(`${suite.server.baseUrl}settings/appearance`);
265264
expect(response?.status()).toBe(200);
266-
await page.getByRole("radio", { name: "UI", exact: true }).click();
265+
await page.getByRole("tab", { name: "UI", exact: true }).click();
267266

268267
const themeInput = page
269268
.locator(".settings-row")

‎ui/src/e2e/plugins-hub-navigation.e2e.test.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,7 @@ suite.define(() => {
237237
});
238238
expect(Math.abs(layout.tabsLeft - layout.titleLeft)).toBeLessThanOrEqual(1);
239239
expect(layout.aboveTabs).toBeGreaterThan(0);
240-
expect(layout.belowTabs - layout.aboveTabs).toBeGreaterThanOrEqual(7);
241-
expect(layout.belowTabs - layout.aboveTabs).toBeLessThanOrEqual(9);
240+
expect(Math.abs(layout.belowTabs - layout.aboveTabs)).toBeLessThanOrEqual(1);
242241
if (label === "desktop") {
243242
expect(Math.abs(layout.tabsLeft - layout.contentLeft)).toBeLessThanOrEqual(1);
244243
}

0 commit comments

Comments
 (0)