From 0073ac106d38c403fd9f55ef4739623de6f89bd0 Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Tue, 23 Jun 2026 11:25:46 +0200 Subject: [PATCH] fix: count default-filled polylines when detecting tintable SVGs --- client/src/utils/__tests__/svg.test.ts | 11 +++++++++++ client/src/utils/svg.ts | 7 +++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/client/src/utils/__tests__/svg.test.ts b/client/src/utils/__tests__/svg.test.ts index e1efaa6664..47d4d78166 100644 --- a/client/src/utils/__tests__/svg.test.ts +++ b/client/src/utils/__tests__/svg.test.ts @@ -100,6 +100,17 @@ describe('isMonochromeSvg', () => { expect(isMonochromeSvg(svg)).toBe(false); }); + it('rejects an explicit badge alongside a default-black polyline glyph', () => { + const svg = + ''; + expect(isMonochromeSvg(svg)).toBe(false); + }); + + it('tints a glyph drawn as a single default-black polyline', () => { + const svg = ''; + expect(isMonochromeSvg(svg)).toBe(true); + }); + it('inherits an ancestor fill instead of assuming the default black', () => { const svg = ''; expect(isMonochromeSvg(svg)).toBe(true); diff --git a/client/src/utils/svg.ts b/client/src/utils/svg.ts index 86ee71e11a..83d1fb3058 100644 --- a/client/src/utils/svg.ts +++ b/client/src/utils/svg.ts @@ -35,8 +35,11 @@ const GRAY_LEVELS = new Map([ /** Paint properties whose color values determine whether an SVG is monochrome. */ const PAINT_PROPS = ['fill', 'stroke', 'stop-color']; -/** Area shapes that render with SVG's default black fill when none is supplied. */ -const FILLABLE_SHAPES = 'path, rect, circle, ellipse, polygon, text'; +/** + * Shapes that render with SVG's default black fill when none is supplied. Includes + * `polyline` (SVG closes it for fill painting) but not `line`, which has no area. + */ +const FILLABLE_SHAPES = 'path, rect, circle, ellipse, polygon, polyline, text'; /** * Containers whose descendants supply functional paint (clipping, masking,