diff --git a/.changeset/wicked-fishes-flow.md b/.changeset/wicked-fishes-flow.md new file mode 100644 index 000000000..19e2d69ff --- /dev/null +++ b/.changeset/wicked-fishes-flow.md @@ -0,0 +1,5 @@ +--- +"victory-candlestick": patch +--- + +Prevents boolean passed to candlestick labels prop from rendering diff --git a/packages/victory-candlestick/src/victory-candlestick.test.tsx b/packages/victory-candlestick/src/victory-candlestick.test.tsx index 910830bd7..659d69684 100644 --- a/packages/victory-candlestick/src/victory-candlestick.test.tsx +++ b/packages/victory-candlestick/src/victory-candlestick.test.tsx @@ -187,6 +187,17 @@ describe("components/victory-candlestick", () => { const points = container.querySelectorAll("rect"); expect(points).toHaveLength(1); }); + + it("does not render a label when it receives true as the lablels prop", () => { + const data = [{ x: 1, open: 10, close: 17, high: 19, low: 8 }]; + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + const { container } = render(); + const trueLabel = Array.from( + container.querySelectorAll("text[id^=candlestick-labels] > tspan"), + ).find((t) => t.textContent === "true"); + expect(trueLabel).toBe(undefined); + }); }); describe("event handling", () => { diff --git a/packages/victory-candlestick/src/victory-candlestick.tsx b/packages/victory-candlestick/src/victory-candlestick.tsx index a70de4e60..d377aa257 100644 --- a/packages/victory-candlestick/src/victory-candlestick.tsx +++ b/packages/victory-candlestick/src/victory-candlestick.tsx @@ -271,7 +271,8 @@ class VictoryCandlestickBase extends React.Component { ); if ( (labelProps as any).text !== undefined && - (labelProps as any).text !== null + (labelProps as any).text !== null && + typeof (labelProps as any).text !== "boolean" ) { return React.cloneElement(labelComponent, labelProps); }