Skip to content

Commit

Permalink
fix for 'Candlestick labels show incorrect midpoint label' (#2931)
Browse files Browse the repository at this point in the history
  • Loading branch information
nstolpe authored Oct 28, 2024
1 parent 953e0ad commit 1d6f7a8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/wicked-fishes-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"victory-candlestick": patch
---

Prevents boolean passed to candlestick labels prop from rendering
11 changes: 11 additions & 0 deletions packages/victory-candlestick/src/victory-candlestick.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(<VictoryCandlestick data={data} labels />);
const trueLabel = Array.from(
container.querySelectorAll("text[id^=candlestick-labels] > tspan"),
).find((t) => t.textContent === "true");
expect(trueLabel).toBe(undefined);
});
});

describe("event handling", () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/victory-candlestick/src/victory-candlestick.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ class VictoryCandlestickBase extends React.Component<VictoryCandlestickProps> {
);
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);
}
Expand Down

0 comments on commit 1d6f7a8

Please sign in to comment.