Skip to content

Commit 95b7a85

Browse files
authored
fix(ui): remove duplicate config section headers
Fix duplicate section title and description rendering in single-section Control UI config pages.\n\nKeeps root multi-section card headers intact, keeps single-section hero copy as the only visible section title, and adds browser coverage for both single-section and root views.\n\nFixes #68003.\n\nThanks @d1rshan.
1 parent c070509 commit 95b7a85

2 files changed

Lines changed: 89 additions & 9 deletions

File tree

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

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -438,20 +438,25 @@ export function renderConfigForm(props: ConfigFormProps) {
438438
sectionKey: string;
439439
label: string;
440440
description: string;
441+
showHeader: boolean;
441442
node: JsonSchema;
442443
nodeValue: unknown;
443444
path: Array<string | number>;
444445
}) => html`
445446
<section class="config-section-card" id=${params.id}>
446-
<div class="config-section-card__header">
447-
<span class="config-section-card__icon">${getSectionIcon(params.sectionKey)}</span>
448-
<div class="config-section-card__titles">
449-
<h3 class="config-section-card__title">${params.label}</h3>
450-
${params.description
451-
? html`<p class="config-section-card__desc">${params.description}</p>`
452-
: nothing}
453-
</div>
454-
</div>
447+
${params.showHeader
448+
? html`
449+
<div class="config-section-card__header">
450+
<span class="config-section-card__icon">${getSectionIcon(params.sectionKey)}</span>
451+
<div class="config-section-card__titles">
452+
<h3 class="config-section-card__title">${params.label}</h3>
453+
${params.description
454+
? html`<p class="config-section-card__desc">${params.description}</p>`
455+
: nothing}
456+
</div>
457+
</div>
458+
`
459+
: nothing}
455460
<div class="config-section-card__content">
456461
${renderNode({
457462
schema: params.node,
@@ -490,6 +495,7 @@ export function renderConfigForm(props: ConfigFormProps) {
490495
sectionKey,
491496
label,
492497
description,
498+
showHeader: false,
493499
node,
494500
nodeValue: scopedValue,
495501
path: [sectionKey, subsectionKey],
@@ -506,6 +512,7 @@ export function renderConfigForm(props: ConfigFormProps) {
506512
sectionKey: key,
507513
label: meta.label,
508514
description: meta.description,
515+
showHeader: activeSection == null,
509516
node,
510517
nodeValue: value[key],
511518
path: [key],

‎ui/src/ui/views/config.browser.test.ts‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,80 @@ describe("config view", () => {
349349
(input as HTMLInputElement).value = "gateway";
350350
input.dispatchEvent(new Event("input", { bubbles: true }));
351351
expect(onSearchChange).toHaveBeenCalledWith("gateway");
352+
});
353+
354+
it("shows section hero and hides nested card header in single-section form view", () => {
355+
const { container } = renderConfigView({
356+
activeSection: "auth",
357+
schema: {
358+
type: "object",
359+
properties: {
360+
auth: {
361+
type: "object",
362+
properties: {
363+
authPermanentBackoffMinutes: {
364+
type: "number",
365+
},
366+
},
367+
},
368+
},
369+
},
370+
formValue: {
371+
auth: {
372+
authPermanentBackoffMinutes: 10,
373+
},
374+
},
375+
originalValue: {
376+
auth: {
377+
authPermanentBackoffMinutes: 10,
378+
},
379+
},
380+
});
352381

382+
const heroTitle = container.querySelector(".config-section-hero__title");
383+
expect(heroTitle?.textContent?.trim()).toBe("Authentication");
384+
expect(container.querySelector(".config-section-card__header")).toBeNull();
385+
});
386+
387+
it("keeps card headers in multi-section root view", () => {
388+
const { container } = renderConfigView({
389+
schema: {
390+
type: "object",
391+
properties: {
392+
auth: {
393+
type: "object",
394+
properties: {},
395+
},
396+
gateway: {
397+
type: "object",
398+
properties: {},
399+
},
400+
},
401+
},
402+
formValue: {
403+
auth: {},
404+
gateway: {},
405+
},
406+
originalValue: {
407+
auth: {},
408+
gateway: {},
409+
},
410+
});
411+
412+
expect(container.querySelectorAll(".config-section-card__header").length).toBeGreaterThan(0);
413+
});
414+
415+
it("clears the active search query", () => {
416+
const container = document.createElement("div");
417+
const onSearchChange = vi.fn();
418+
render(
419+
renderConfig({
420+
...baseProps(),
421+
searchQuery: "gateway",
422+
onSearchChange,
423+
}),
424+
container,
425+
);
353426
const clearButton = container.querySelector<HTMLButtonElement>(".config-search__clear");
354427
expect(clearButton).toBeTruthy();
355428
clearButton?.click();

0 commit comments

Comments
 (0)