Skip to content

Commit be85ee0

Browse files
committed
fix(dashboard): treat a blank logoHeight as unset, not zero
Review follow-up (non-blocking). A blank branding.logoHeight survives pick into config.json, and Number("") is 0, which passed the finite check and clamped to the 16px minimum instead of the 36px default. Trim blank strings to NaN so they fall back to the default. Also fix a stale comment in SchemaForm that still described the old ["number", "string"] shape after the switch to ["string", "integer"]. Assisted-by: LLM Signed-off-by: IvanHunters <[email protected]>
1 parent bb50cb4 commit be85ee0

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

‎packages/system/dashboard/images/console/apps/console/src/__tests__/header-logo.test.tsx‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ describe("Header logo sizing", () => {
4040
expect(container.querySelector("img")?.style.height).toBe("48px")
4141
})
4242

43+
it("treats a blank-string logoHeight as unset, not zero", () => {
44+
// `pick` keeps an empty branding.logoHeight, so config.json may carry "".
45+
// Number("") is 0, which would clamp to the 16px minimum — fall back to 36.
46+
for (const blank of ["", " "]) {
47+
const { container } = renderHeader({ logoHeight: blank })
48+
expect(container.querySelector("img")?.style.height).toBe("36px")
49+
}
50+
})
51+
4352
it("passes logoHeight through AppShell to the header logo", () => {
4453
const { container } = render(
4554
<MemoryRouter>

‎packages/system/dashboard/images/console/apps/console/src/components/SchemaForm.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ export const SchemaForm = forwardRef<SchemaFormHandle, SchemaFormProps>(function
311311
// Scoped to schemas where resourceQuotas values are quantities (the
312312
// cozystack-tenants chart shape) to avoid activating on unrelated CRDs.
313313
// The chart types them as int-or-string, which sanitizeSchema turns into
314-
// `["number", "string"]`, so accept a string type or a type array that
314+
// `["string", "integer"]`, so accept a string type or a type array that
315315
// includes "string".
316316
const rqSchema = schema.properties?.resourceQuotas as
317317
| { additionalProperties?: { type?: unknown } }

‎packages/system/dashboard/images/console/packages/ui/src/components/layout/Header.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ const MIN_LOGO_HEIGHT = 16
3535
const MAX_LOGO_HEIGHT = 80
3636

3737
function resolveLogoHeight(height?: number | string): number {
38-
const n = typeof height === "string" ? Number(height) : height
38+
// A blank string is "unset", not zero: Number("") is 0, which would clamp to
39+
// the minimum. Treat it as NaN so it falls back to the default.
40+
const n = typeof height === "string" ? (height.trim() === "" ? NaN : Number(height)) : height
3941
if (typeof n !== "number" || !Number.isFinite(n)) return DEFAULT_LOGO_HEIGHT
4042
return Math.max(MIN_LOGO_HEIGHT, Math.min(MAX_LOGO_HEIGHT, n))
4143
}

0 commit comments

Comments
 (0)