Skip to content

Commit 983234b

Browse files
authored
Merge pull request #1799 from loganwedwards/feature/eventhandlers-additional-args
Update EventPropTypeInterface to include prop arg
2 parents 0adb1b1 + 48ea241 commit 983234b

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

packages/victory-core/src/index.d.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -531,10 +531,16 @@ export interface EventPropTypeInterface<TTarget, TEventKey> {
531531
eventHandlers: {
532532
[key: string]:
533533
| {
534-
(event: React.SyntheticEvent<any>): EventCallbackInterface<TTarget, TEventKey>;
534+
(event: React.SyntheticEvent<any>, props?: any): EventCallbackInterface<
535+
TTarget,
536+
TEventKey
537+
>;
535538
}
536539
| {
537-
(event: React.SyntheticEvent<any>): EventCallbackInterface<TTarget, TEventKey>[];
540+
(event: React.SyntheticEvent<any>, props?: any): EventCallbackInterface<
541+
TTarget,
542+
TEventKey
543+
>[];
538544
};
539545
};
540546
}

test/client/spec/victory-bar/victory-bar.spec.js

+10
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,14 @@ describe("components/victory-bar", () => {
137137

138138
it("attaches an event to data", () => {
139139
const clickHandler = sinon.spy();
140+
const data = [
141+
{ x: 0, y: 0, label: "0" },
142+
{ x: 1, y: 1, label: "1" },
143+
{ x: 2, y: 2, label: "2" }
144+
];
140145
const wrapper = mount(
141146
<VictoryBar
147+
data={data}
142148
events={[
143149
{
144150
target: "data",
@@ -156,6 +162,10 @@ describe("components/victory-bar", () => {
156162
expect(omit(clickHandler.args[index][1], ["events", "key"])).to.eql(
157163
omit(initialProps, ["events", "key"])
158164
);
165+
// It should also include the datum
166+
expect(clickHandler.args[index][1].datum).to.include({
167+
...data[index]
168+
});
159169
expect(`${clickHandler.args[index][2]}`).to.eql(`${index}`);
160170
});
161171
});

0 commit comments

Comments
 (0)