From 6b607f37cf60b5121278885d04abaad3683019f6 Mon Sep 17 00:00:00 2001 From: Endi Modric Date: Fri, 8 Feb 2019 00:48:32 +0100 Subject: [PATCH] [DatePicker] fix onChange on month change after initial day selection (#3343) * fix onChange doesn't fire on month change after initial day selection Fixes #3340 * change !== to != operator * add test onChange fired when month is changed for uncontrolled datepicker --- packages/datetime/src/datePicker.tsx | 2 +- packages/datetime/test/datePickerTests.tsx | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/datetime/src/datePicker.tsx b/packages/datetime/src/datePicker.tsx index f08b0fc8d7..a5cdd9650c 100644 --- a/packages/datetime/src/datePicker.tsx +++ b/packages/datetime/src/datePicker.tsx @@ -246,7 +246,7 @@ export class DatePicker extends AbstractPureComponent", () => { assert.isTrue(onChange.calledOnce); }); + it("onChange fired when month is changed", () => { + const onChange = sinon.spy(); + const { getDay, clickNextMonth } = wrap(); + assert.isTrue(onChange.notCalled); + getDay().simulate("click"); + assert.isTrue(onChange.calledOnce, "expected onChange called"); + clickNextMonth(); + assert.isTrue(onChange.calledTwice, "expected onChange called again"); + }); + it("selected day updates are automatic", () => { const { assertSelectedDays, getDay } = wrap(); assertSelectedDays();