diff --git a/packages/core/src/components/forms/asyncControllableInput.tsx b/packages/core/src/components/forms/asyncControllableInput.tsx index abcba9a18f..4081c43379 100644 --- a/packages/core/src/components/forms/asyncControllableInput.tsx +++ b/packages/core/src/components/forms/asyncControllableInput.tsx @@ -22,6 +22,8 @@ export interface IAsyncControllableInputProps inputRef?: React.LegacyRef; } +type InputValue = IAsyncControllableInputProps["value"]; + export interface IAsyncControllableInputState { /** * Whether we are in the middle of a composition event. @@ -34,13 +36,18 @@ export interface IAsyncControllableInputState { * It may be updated by a parent component. * @default "" */ - externalValue: IAsyncControllableInputProps["value"]; + value: InputValue; + + /** + * The latest input value, which updates during IME composition. Defaults to props.value. + */ + nextValue: InputValue; /** - * The latest input value, which updates during IME composition. If undefined, we use - * externalValue instead. + * Whether there is a pending update we are expecting from a parent component. + * @default false */ - localValue: IAsyncControllableInputProps["value"]; + hasPendingUpdate: boolean; } /** @@ -50,8 +57,6 @@ export interface IAsyncControllableInputState { * asychronously. This might happen if a component chooses to do async validation of a value * returned by the input's `onChange` callback. * - * Implementation adapted from https://jsfiddle.net/m792qtys/ (linked in the above issue thread). - * * Note: this component does not apply any Blueprint-specific styling. */ @polyfill @@ -60,25 +65,60 @@ export class AsyncControllableInput extends React.PureComponent< IAsyncControllableInputState > { public state: IAsyncControllableInputState = { - externalValue: this.props.value, + hasPendingUpdate: false, isComposing: false, - localValue: this.props.value, + nextValue: this.props.value, + value: this.props.value, }; - public static getDerivedStateFromProps({ value }: IAsyncControllableInputProps) { - return { - externalValue: value, - }; + public static getDerivedStateFromProps( + nextProps: IAsyncControllableInputProps, + nextState: IAsyncControllableInputState, + ): Partial | null { + if (nextState.isComposing || nextProps.value === undefined) { + // don't derive anything from props if: + // - in uncontrolled mode, OR + // - currently composing, since we'll do that after composition ends + return null; + } + + const userTriggeredUpdate = nextState.nextValue !== nextState.value; + + if (userTriggeredUpdate) { + if (nextProps.value === nextState.nextValue) { + // parent has processed and accepted our update + if (nextState.hasPendingUpdate) { + return { value: nextProps.value, hasPendingUpdate: false }; + } else { + return { value: nextState.nextValue }; + } + } else { + if (nextProps.value === nextState.value) { + // we have sent the update to our parent, but it has not been processed yet. just wait. + // DO NOT set nextValue here, since that will temporarily render a potentially stale controlled value, + // causing the cursor to jump once the new value is accepted + return { hasPendingUpdate: true }; + } + // accept controlled update overriding user action + return { value: nextProps.value, nextValue: nextProps.value, hasPendingUpdate: false }; + } + } else { + // accept controlled update, could be confirming or denying user action + return { value: nextProps.value, nextValue: nextProps.value, hasPendingUpdate: false }; + } } public render() { - const { isComposing, externalValue, localValue } = this.state; + const { isComposing, hasPendingUpdate: pendingUpdate, value, nextValue } = this.state; const { inputRef, ...restProps } = this.props; return ( ) => { const { value } = e.target; - this.setState({ localValue: value }); + this.setState({ nextValue: value }); this.props.onChange?.(e); }; } diff --git a/packages/core/src/components/forms/text-inputs.md b/packages/core/src/components/forms/text-inputs.md index b24b76edb6..05b0af6555 100644 --- a/packages/core/src/components/forms/text-inputs.md +++ b/packages/core/src/components/forms/text-inputs.md @@ -9,7 +9,8 @@ Blueprint provides two ways to create a text input: @## Input group -An input group allows you to add icons and buttons _within_ a text input to expand its +Input groups are a basic building block used to render text inputs across many Blueprint components. +They allow you to add icons and buttons _within_ a text input to expand its appearance and functionality. For example, you might use an input group to build a visibility toggle for a password field. @@ -28,6 +29,12 @@ a controlled or uncontrolled fashion. In addition to its own props, it supports all valid props for HTML `` elements and proxies them to that element in the DOM; the most common ones are detailed below. +If controlled with the `value` prop, `InputGroup` has support for _asynchronous updates_, which may +occur with some form handling libraries like `redux-form`. This is not generally encouraged (a value +returned from `onChange` should generally be sent back to the component as a controlled `value` synchronously), +but there is basic support for it. Note that the input cursor may jump to the end of the input if the speed +of text entry (time between change events) is faster than the speed of the async update. + @interface IInputGroupProps @### CSS diff --git a/packages/core/test/forms/asyncControllableInputTests.tsx b/packages/core/test/forms/asyncControllableInputTests.tsx index 66096a9673..6d619ef5ed 100644 --- a/packages/core/test/forms/asyncControllableInputTests.tsx +++ b/packages/core/test/forms/asyncControllableInputTests.tsx @@ -23,60 +23,80 @@ import { spy } from "sinon"; import { AsyncControllableInput } from "../../src/components/forms/asyncControllableInput"; describe("", () => { - it("renders an input", () => { - const wrapper = mount(); - assert.strictEqual(wrapper.childAt(0).type(), "input"); - }); + describe("uncontrolled mode", () => { + it("renders an input", () => { + const handleChangeSpy = spy(); + const wrapper = mount(); + assert.strictEqual(wrapper.childAt(0).type(), "input"); + }); - it("accepts controlled updates", () => { - const wrapper = mount(); - assert.strictEqual(wrapper.find("input").prop("value"), "hi"); - wrapper.setProps({ value: "bye" }); - assert.strictEqual(wrapper.find("input").prop("value"), "bye"); + it("triggers onChange", () => { + const handleChangeSpy = spy(); + const wrapper = mount(); + const input = wrapper.find("input"); + input.simulate("change", { target: { value: "bye" } }); + const simulatedEvent: React.ChangeEvent = handleChangeSpy.getCall(0).lastArg; + assert.strictEqual(simulatedEvent.target.value, "bye"); + }); }); - it("triggers onChange events during composition", () => { - const handleChangeSpy = spy(); - const wrapper = mount(); - const input = wrapper.find("input"); + describe("controlled mode", () => { + it("renders an input", () => { + const wrapper = mount(); + assert.strictEqual(wrapper.childAt(0).type(), "input"); + }); - input.simulate("compositionstart", { data: "" }); - input.simulate("compositionupdate", { data: " " }); - // some browsers trigger this change event during composition, so we test to ensure that our wrapper component does too - input.simulate("change", { target: { value: "hi " } }); - input.simulate("compositionupdate", { data: " ." }); - input.simulate("change", { target: { value: "hi ." } }); - input.simulate("compositionend", { data: " ." }); + it("accepts controlled updates", () => { + const wrapper = mount(); + assert.strictEqual(wrapper.find("input").prop("value"), "hi"); + wrapper.setProps({ value: "bye" }); + assert.strictEqual(wrapper.find("input").prop("value"), "bye"); + }); - assert.strictEqual(handleChangeSpy.callCount, 2); - }); + it("triggers onChange events during composition", () => { + const handleChangeSpy = spy(); + const wrapper = mount(); + const input = wrapper.find("input"); - it("external updates do not override in-progress composition", async () => { - const wrapper = mount(); - const input = wrapper.find("input"); + input.simulate("compositionstart", { data: "" }); + input.simulate("compositionupdate", { data: " " }); + // some browsers trigger this change event during composition, so we test to ensure that our wrapper component does too + input.simulate("change", { target: { value: "hi " } }); + input.simulate("compositionupdate", { data: " ." }); + input.simulate("change", { target: { value: "hi ." } }); + input.simulate("compositionend", { data: " ." }); - input.simulate("compositionstart", { data: "" }); - input.simulate("compositionupdate", { data: " " }); - input.simulate("change", { target: { value: "hi " } }); + assert.strictEqual(handleChangeSpy.callCount, 2); + }); - await Promise.resolve(); - wrapper.setProps({ value: "bye" }).update(); + it("external updates DO NOT override in-progress composition", async () => { + const wrapper = mount(); + const input = wrapper.find("input"); - assert.strictEqual(wrapper.find("input").prop("value"), "hi "); - }); + input.simulate("compositionstart", { data: "" }); + input.simulate("compositionupdate", { data: " " }); + input.simulate("change", { target: { value: "hi " } }); + + await Promise.resolve(); + wrapper.setProps({ value: "bye" }).update(); + + assert.strictEqual(wrapper.find("input").prop("value"), "hi "); + }); - it("external updates flush after composition ends", async () => { - const wrapper = mount(); - const input = wrapper.find("input"); + it("external updates flush after composition ends", async () => { + const wrapper = mount(); + const input = wrapper.find("input"); - input.simulate("compositionstart", { data: "" }); - input.simulate("compositionupdate", { data: " " }); - input.simulate("change", { target: { value: "hi " } }); - input.simulate("compositionend", { data: " " }); + input.simulate("compositionstart", { data: "" }); + input.simulate("compositionupdate", { data: " " }); + input.simulate("change", { target: { value: "hi " } }); + input.simulate("compositionend", { data: " " }); - await Promise.resolve(); - wrapper.setProps({ value: "bye" }).update(); + await Promise.resolve(); + // we are "rejecting" the composition here by supplying a different controlled value + wrapper.setProps({ value: "bye" }).update(); - assert.strictEqual(wrapper.find("input").prop("value"), "bye"); + assert.strictEqual(wrapper.find("input").prop("value"), "bye"); + }); }); }); diff --git a/packages/datetime/test/dateInputTests.tsx b/packages/datetime/test/dateInputTests.tsx index 619ee18e96..f4e3393400 100644 --- a/packages/datetime/test/dateInputTests.tsx +++ b/packages/datetime/test/dateInputTests.tsx @@ -674,8 +674,10 @@ describe("", () => { it("parseDate returns false renders invalid date", () => { const invalidParse = sinon.stub().returns(false); const wrapper = mount(); - wrapper.find("input").simulate("change", { target: { value: "invalid" } }); - assert.strictEqual(wrapper.find("input").prop("value"), ""); + const input = wrapper.find("input"); + input.simulate("change", { target: { value: "invalid" } }); + input.simulate("blur"); + assert.strictEqual(wrapper.find("input").prop("value"), DateInput.defaultProps.invalidDateMessage); }); }); diff --git a/packages/datetime/test/dateRangeInputTests.tsx b/packages/datetime/test/dateRangeInputTests.tsx index 23b052a376..e715713d22 100644 --- a/packages/datetime/test/dateRangeInputTests.tsx +++ b/packages/datetime/test/dateRangeInputTests.tsx @@ -137,7 +137,7 @@ describe("", () => { it("shows empty fields when no date range is selected", () => { const { root } = wrap(); - assertInputTextsEqual(root, "", ""); + assertInputValuesEqual(root, "", ""); }); it("throws error if value === null", () => { @@ -502,7 +502,7 @@ describe("", () => { getEndInput(root).simulate("focus"); getDayElement(END_DAY).simulate("click"); getDayElement(START_DAY).simulate("click"); - assertInputTextsEqual(root, START_STR, START_STR); + assertInputValuesEqual(root, START_STR, START_STR); }); it("allows start and end to be the same day when typing", () => { @@ -511,7 +511,7 @@ describe("", () => { ); changeEndInputText(root, ""); changeEndInputText(root, START_STR); - assertInputTextsEqual(root, START_STR, START_STR); + assertInputValuesEqual(root, START_STR, START_STR); }); }); @@ -546,22 +546,22 @@ describe("", () => { describe("when uncontrolled", () => { it("Shows empty fields when defaultValue is [null, null]", () => { const { root } = wrap(); - assertInputTextsEqual(root, "", ""); + assertInputValuesEqual(root, "", ""); }); it("Shows empty start field and formatted date in end field when defaultValue is [null, ]", () => { const { root } = wrap(); - assertInputTextsEqual(root, "", END_STR); + assertInputValuesEqual(root, "", END_STR); }); it("Shows empty end field and formatted date in start field when defaultValue is [, null]", () => { const { root } = wrap(); - assertInputTextsEqual(root, START_STR, ""); + assertInputValuesEqual(root, START_STR, ""); }); it("Shows formatted dates in both fields when defaultValue is [, ]", () => { const { root } = wrap(); - assertInputTextsEqual(root, START_STR, END_STR); + assertInputValuesEqual(root, START_STR, END_STR); }); it("Pressing Enter saves the inputted date and closes the popover", () => { @@ -610,19 +610,19 @@ describe("", () => { getDayElement(END_DAY).simulate("click"); assertDateRangesEqual(onChange.getCall(0).args[0], [START_STR, END_STR]); - assertInputTextsEqual(root, START_STR, END_STR); + assertInputValuesEqual(root, START_STR, END_STR); getDayElement(START_DAY).simulate("click"); assertDateRangesEqual(onChange.getCall(1).args[0], [null, END_STR]); - assertInputTextsEqual(root, "", END_STR); + assertInputValuesEqual(root, "", END_STR); getDayElement(END_DAY).simulate("click"); assertDateRangesEqual(onChange.getCall(2).args[0], [null, null]); - assertInputTextsEqual(root, "", ""); + assertInputValuesEqual(root, "", ""); getDayElement(START_DAY).simulate("click"); assertDateRangesEqual(onChange.getCall(3).args[0], [START_STR, null]); - assertInputTextsEqual(root, START_STR, ""); + assertInputValuesEqual(root, START_STR, ""); expect(onChange.callCount).to.equal(4); }); @@ -635,12 +635,12 @@ describe("", () => { changeStartInputText(root, START_STR_2); expect(onChange.callCount).to.equal(1); assertDateRangesEqual(onChange.getCall(0).args[0], [START_STR_2, END_STR]); - assertInputTextsEqual(root, START_STR_2, END_STR); + assertInputValuesEqual(root, START_STR_2, END_STR); changeEndInputText(root, END_STR_2); expect(onChange.callCount).to.equal(2); assertDateRangesEqual(onChange.getCall(1).args[0], [START_STR_2, END_STR_2]); - assertInputTextsEqual(root, START_STR_2, END_STR_2); + assertInputValuesEqual(root, START_STR_2, END_STR_2); }); it(`Typing in a field while hovering over a date shows the typed date, not the hovered date`, () => { @@ -652,7 +652,7 @@ describe("", () => { getStartInput(root).simulate("focus"); getDayElement(1).simulate("mouseenter"); changeStartInputText(root, START_STR_2); - assertInputTextsEqual(root, START_STR_2, END_STR); + assertInputValuesEqual(root, START_STR_2, END_STR); }); describe("Typing an out-of-range date", () => { @@ -693,7 +693,7 @@ describe("", () => { runTestForEachScenario((inputGetterFn, inputString) => { changeInputText(inputGetterFn(root), inputString); inputGetterFn(root).simulate("blur"); - assertInputTextEquals(inputGetterFn(root), OUT_OF_RANGE_MESSAGE); + assertInputValueEquals(inputGetterFn(root), OUT_OF_RANGE_MESSAGE); }); }); @@ -702,7 +702,7 @@ describe("", () => { changeInputText(inputGetterFn(root), inputString); inputGetterFn(root).simulate("blur"); inputGetterFn(root).simulate("focus"); - assertInputTextEquals(inputGetterFn(root), inputString); + assertInputValueEquals(inputGetterFn(root), inputString); }); }); @@ -737,7 +737,7 @@ describe("", () => { inputGetterFn(root).simulate("focus"); changeInputText(inputGetterFn(root), IN_RANGE_DATE_STR); inputGetterFn(root).simulate("blur"); - assertInputTextEquals(inputGetterFn(root), IN_RANGE_DATE_STR); + assertInputValueEquals(inputGetterFn(root), IN_RANGE_DATE_STR); }); }); @@ -781,7 +781,7 @@ describe("", () => { inputGetterFn(root).simulate("focus"); changeInputText(inputGetterFn(root), INVALID_STR); inputGetterFn(root).simulate("blur"); - assertInputTextEquals(inputGetterFn(root), INVALID_MESSAGE); + assertInputValueEquals(inputGetterFn(root), INVALID_MESSAGE); }); }); @@ -791,7 +791,7 @@ describe("", () => { changeInputText(inputGetterFn(root), INVALID_STR); inputGetterFn(root).simulate("blur"); inputGetterFn(root).simulate("focus"); - assertInputTextEquals(inputGetterFn(root), INVALID_MESSAGE); + assertInputValueEquals(inputGetterFn(root), INVALID_MESSAGE); }); }); @@ -831,7 +831,7 @@ describe("", () => { inputGetterFn(root).simulate("focus"); changeInputText(inputGetterFn(root), VALID_STR); inputGetterFn(root).simulate("blur"); - assertInputTextEquals(inputGetterFn(root), VALID_STR); + assertInputValueEquals(inputGetterFn(root), VALID_STR); }); }); @@ -889,11 +889,11 @@ describe("", () => { getStartInput(root).simulate("focus"); changeInputText(getStartInput(root), OVERLAPPING_START_DT_STR); getStartInput(root).simulate("blur"); - assertInputTextEquals(getStartInput(root), OVERLAPPING_START_DT_STR); + assertInputValueEquals(getStartInput(root), OVERLAPPING_START_DT_STR); getEndInput(root).simulate("focus"); changeInputText(getEndInput(root), OVERLAPPING_END_DT_STR); getEndInput(root).simulate("blur"); - assertInputTextEquals(getEndInput(root), OVERLAPPING_DATES_MESSAGE); + assertInputValueEquals(getEndInput(root), OVERLAPPING_DATES_MESSAGE); }); }); }); @@ -925,7 +925,7 @@ describe("", () => { it("shows an error message in the end field right away", () => { getStartInput(root).simulate("focus"); changeInputText(getStartInput(root), OVERLAPPING_START_STR); - assertInputTextEquals(getEndInput(root), OVERLAPPING_DATES_MESSAGE); + assertInputValueEquals(getEndInput(root), OVERLAPPING_DATES_MESSAGE); }); it("shows the offending date in the end field on focus in the end field", () => { @@ -933,7 +933,7 @@ describe("", () => { changeInputText(getStartInput(root), OVERLAPPING_START_STR); getStartInput(root).simulate("blur"); getEndInput(root).simulate("focus"); - assertInputTextEquals(getEndInput(root), END_STR); + assertInputValueEquals(getEndInput(root), END_STR); }); it("calls onError with [, { @@ -957,7 +957,7 @@ describe("", () => { getStartInput(root).simulate("focus"); changeInputText(getStartInput(root), OVERLAPPING_START_STR); changeInputText(getStartInput(root), START_STR); - assertInputTextEquals(getEndInput(root), END_STR); + assertInputValueEquals(getEndInput(root), END_STR); }); }); @@ -965,9 +965,9 @@ describe("", () => { it("shows an error message in the end field on blur", () => { getEndInput(root).simulate("focus"); changeInputText(getEndInput(root), OVERLAPPING_END_STR); - assertInputTextEquals(getEndInput(root), OVERLAPPING_END_STR); + assertInputValueEquals(getEndInput(root), OVERLAPPING_END_STR); getEndInput(root).simulate("blur"); - assertInputTextEquals(getEndInput(root), OVERLAPPING_DATES_MESSAGE); + assertInputValueEquals(getEndInput(root), OVERLAPPING_DATES_MESSAGE); }); it("shows the offending date in the end field on re-focus", () => { @@ -975,7 +975,7 @@ describe("", () => { changeInputText(getEndInput(root), OVERLAPPING_END_STR); getEndInput(root).simulate("blur"); getEndInput(root).simulate("focus"); - assertInputTextEquals(getEndInput(root), OVERLAPPING_END_STR); + assertInputValueEquals(getEndInput(root), OVERLAPPING_END_STR); }); it("calls onError with [, ] on blur", () => { @@ -1002,7 +1002,7 @@ describe("", () => { getEndInput(root).simulate("focus"); changeInputText(getEndInput(root), END_STR); getEndInput(root).simulate("blur"); - assertInputTextEquals(getEndInput(root), END_STR); + assertInputValueEquals(getEndInput(root), END_STR); }); }); }); @@ -1111,7 +1111,7 @@ describe("", () => { }); it("shows [, null] in input fields", () => { - assertInputTextsEqual(root, HOVER_TEST_DATE_CONFIG.str, ""); + assertInputValuesEqual(root, HOVER_TEST_DATE_CONFIG.str, ""); }); it("keeps focus on start field", () => { @@ -1124,7 +1124,7 @@ describe("", () => { }); it("sets selection to [, null]", () => { - assertInputTextsEqual(root, HOVER_TEST_DATE_CONFIG.str, ""); + assertInputValuesEqual(root, HOVER_TEST_DATE_CONFIG.str, ""); }); it("moves focus to end field", () => { @@ -1138,7 +1138,7 @@ describe("", () => { }); it("shows [null, null] in input fields", () => { - assertInputTextsEqual(root, "", ""); + assertInputValuesEqual(root, "", ""); }); it("keeps focus on start field", () => { @@ -1154,25 +1154,20 @@ describe("", () => { }); it("shows [null, ] in input fields", () => { - assertInputTextsEqual(root, "", HOVER_TEST_DATE_CONFIG.str); + assertInputValuesEqual(root, "", HOVER_TEST_DATE_CONFIG.str); }); it("keeps focus on end field", () => { assertEndInputFocused(root); }); - it("sets selection to [null, ] on click", () => { - getDayElement(HOVER_TEST_DATE_CONFIG.day).simulate("click"); - assertInputTextsEqual(root, "", HOVER_TEST_DATE_CONFIG.str); - }); - describe("on click", () => { beforeEach(() => { getDayElement(HOVER_TEST_DATE_CONFIG.day).simulate("click"); }); it("sets selection to [null, ]", () => { - assertInputTextsEqual(root, "", HOVER_TEST_DATE_CONFIG.str); + assertInputValuesEqual(root, "", HOVER_TEST_DATE_CONFIG.str); }); it("moves focus to start field", () => { @@ -1186,7 +1181,7 @@ describe("", () => { }); it("shows [null, null] in input fields", () => { - assertInputTextsEqual(root, "", ""); + assertInputValuesEqual(root, "", ""); }); it("keeps focus on end field", () => { @@ -1216,7 +1211,7 @@ describe("", () => { }); it("shows [, null] in input fields", () => { - assertInputTextsEqual(root, DATE_CONFIG.str, ""); + assertInputValuesEqual(root, DATE_CONFIG.str, ""); }); it("keeps focus on start field", () => { @@ -1229,7 +1224,7 @@ describe("", () => { }); it("sets selection to [, null]", () => { - assertInputTextsEqual(root, DATE_CONFIG.str, ""); + assertInputValuesEqual(root, DATE_CONFIG.str, ""); }); it("moves focus to end field", () => { @@ -1243,7 +1238,7 @@ describe("", () => { }); it("shows [, null] in input fields", () => { - assertInputTextsEqual(root, SELECTED_RANGE[0].str, ""); + assertInputValuesEqual(root, SELECTED_RANGE[0].str, ""); }); it("keeps focus on start field", () => { @@ -1260,7 +1255,7 @@ describe("", () => { }); it("shows [, null] in input fields", () => { - assertInputTextsEqual(root, DATE_CONFIG.str, ""); + assertInputValuesEqual(root, DATE_CONFIG.str, ""); }); it("keeps focus on start field", () => { @@ -1273,7 +1268,7 @@ describe("", () => { }); it("sets selection to [, null]", () => { - assertInputTextsEqual(root, DATE_CONFIG.str, ""); + assertInputValuesEqual(root, DATE_CONFIG.str, ""); }); it("moves focus to end field", () => { @@ -1287,7 +1282,7 @@ describe("", () => { }); it("shows [, null] in input fields", () => { - assertInputTextsEqual(root, SELECTED_RANGE[0].str, ""); + assertInputValuesEqual(root, SELECTED_RANGE[0].str, ""); }); it("keeps focus on start field", () => { @@ -1304,7 +1299,7 @@ describe("", () => { }); it("shows [null, null] in input fields", () => { - assertInputTextsEqual(root, "", ""); + assertInputValuesEqual(root, "", ""); }); it("keeps focus on start field", () => { @@ -1317,7 +1312,7 @@ describe("", () => { }); it("sets selection to [null, null]", () => { - assertInputTextsEqual(root, "", ""); + assertInputValuesEqual(root, "", ""); }); it("keeps focus on start field", () => { @@ -1331,7 +1326,7 @@ describe("", () => { }); it("shows [, null] in input fields", () => { - assertInputTextsEqual(root, SELECTED_RANGE[0].str, ""); + assertInputValuesEqual(root, SELECTED_RANGE[0].str, ""); }); it("keeps focus on start field", () => { @@ -1354,7 +1349,7 @@ describe("", () => { }); it("shows [, ] in input fields", () => { - assertInputTextsEqual(root, SELECTED_RANGE[0].str, DATE_CONFIG.str); + assertInputValuesEqual(root, SELECTED_RANGE[0].str, DATE_CONFIG.str); }); it("keeps focus on end field", () => { @@ -1367,7 +1362,7 @@ describe("", () => { }); it("sets selection to [, ]", () => { - assertInputTextsEqual(root, SELECTED_RANGE[0].str, DATE_CONFIG.str); + assertInputValuesEqual(root, SELECTED_RANGE[0].str, DATE_CONFIG.str); }); it("keeps focus on end field", () => { @@ -1381,7 +1376,7 @@ describe("", () => { }); it("shows [, null] in input fields", () => { - assertInputTextsEqual(root, SELECTED_RANGE[0].str, ""); + assertInputValuesEqual(root, SELECTED_RANGE[0].str, ""); }); it("keeps focus on end field", () => { @@ -1398,7 +1393,7 @@ describe("", () => { }); it("shows [, ] in input fields", () => { - assertInputTextsEqual(root, DATE_CONFIG.str, SELECTED_RANGE[0].str); + assertInputValuesEqual(root, DATE_CONFIG.str, SELECTED_RANGE[0].str); }); it("moves focus to start field", () => { @@ -1411,7 +1406,7 @@ describe("", () => { }); it("sets selection to [, ]", () => { - assertInputTextsEqual(root, DATE_CONFIG.str, SELECTED_RANGE[0].str); + assertInputValuesEqual(root, DATE_CONFIG.str, SELECTED_RANGE[0].str); }); it("leaves focus on start field", () => { @@ -1425,7 +1420,7 @@ describe("", () => { }); it("shows [, null] in input fields", () => { - assertInputTextsEqual(root, SELECTED_RANGE[0].str, ""); + assertInputValuesEqual(root, SELECTED_RANGE[0].str, ""); }); it("keeps focus on end field", () => { @@ -1442,7 +1437,7 @@ describe("", () => { }); it("shows [null, null] in input fields", () => { - assertInputTextsEqual(root, "", ""); + assertInputValuesEqual(root, "", ""); }); it("moves focus to start field", () => { @@ -1455,7 +1450,7 @@ describe("", () => { }); it("sets selection to [null, null] on click", () => { - assertInputTextsEqual(root, "", ""); + assertInputValuesEqual(root, "", ""); }); it("leaves focus on start field", () => { @@ -1469,7 +1464,7 @@ describe("", () => { }); it("shows [, null] in input fields", () => { - assertInputTextsEqual(root, SELECTED_RANGE[0].str, ""); + assertInputValuesEqual(root, SELECTED_RANGE[0].str, ""); }); it("keeps focus on end field", () => { @@ -1500,7 +1495,7 @@ describe("", () => { }); it("shows [, ] in input fields", () => { - assertInputTextsEqual(root, DATE_CONFIG.str, SELECTED_RANGE[1].str); + assertInputValuesEqual(root, DATE_CONFIG.str, SELECTED_RANGE[1].str); }); it("keeps focus on start field", () => { @@ -1513,7 +1508,7 @@ describe("", () => { }); it("sets selection to [, ]", () => { - assertInputTextsEqual(root, DATE_CONFIG.str, SELECTED_RANGE[1].str); + assertInputValuesEqual(root, DATE_CONFIG.str, SELECTED_RANGE[1].str); }); it("keeps focus on start field", () => { @@ -1527,7 +1522,7 @@ describe("", () => { }); it("shows [null, ] in input fields", () => { - assertInputTextsEqual(root, "", SELECTED_RANGE[1].str); + assertInputValuesEqual(root, "", SELECTED_RANGE[1].str); }); it("keeps focus on start field", () => { @@ -1544,7 +1539,7 @@ describe("", () => { }); it("shows [, ] in input fields", () => { - assertInputTextsEqual(root, SELECTED_RANGE[1].str, DATE_CONFIG.str); + assertInputValuesEqual(root, SELECTED_RANGE[1].str, DATE_CONFIG.str); }); it("moves focus to end field", () => { @@ -1557,7 +1552,7 @@ describe("", () => { }); it("sets selection to [, ] on click", () => { - assertInputTextsEqual(root, SELECTED_RANGE[1].str, DATE_CONFIG.str); + assertInputValuesEqual(root, SELECTED_RANGE[1].str, DATE_CONFIG.str); }); it("keeps focus on end field", () => { @@ -1571,7 +1566,7 @@ describe("", () => { }); it("shows [null, ] in input fields", () => { - assertInputTextsEqual(root, "", SELECTED_RANGE[1].str); + assertInputValuesEqual(root, "", SELECTED_RANGE[1].str); }); it("moves focus back to start field", () => { @@ -1588,7 +1583,7 @@ describe("", () => { }); it("shows [null, null] in input fields", () => { - assertInputTextsEqual(root, "", ""); + assertInputValuesEqual(root, "", ""); }); it("moves focus to end field", () => { @@ -1601,7 +1596,7 @@ describe("", () => { }); it("sets selection to [null, null] on click", () => { - assertInputTextsEqual(root, "", ""); + assertInputValuesEqual(root, "", ""); }); it("moves focus to start field", () => { @@ -1615,7 +1610,7 @@ describe("", () => { }); it("shows [null, ] in input fields", () => { - assertInputTextsEqual(root, "", SELECTED_RANGE[1].str); + assertInputValuesEqual(root, "", SELECTED_RANGE[1].str); }); it("keeps focus on start field", () => { @@ -1638,7 +1633,7 @@ describe("", () => { }); it("shows [null, ] in input fields", () => { - assertInputTextsEqual(root, "", DATE_CONFIG.str); + assertInputValuesEqual(root, "", DATE_CONFIG.str); }); it("keeps focus on end field", () => { @@ -1651,7 +1646,7 @@ describe("", () => { }); it("sets selection to [null, ]", () => { - assertInputTextsEqual(root, "", DATE_CONFIG.str); + assertInputValuesEqual(root, "", DATE_CONFIG.str); }); it("moves focus to start field", () => { @@ -1665,7 +1660,7 @@ describe("", () => { }); it("shows [null, ] in input fields", () => { - assertInputTextsEqual(root, "", SELECTED_RANGE[1].str); + assertInputValuesEqual(root, "", SELECTED_RANGE[1].str); }); it("keeps focus on end field", () => { @@ -1682,7 +1677,7 @@ describe("", () => { }); it("shows [null, ] in input fields", () => { - assertInputTextsEqual(root, "", DATE_CONFIG.str); + assertInputValuesEqual(root, "", DATE_CONFIG.str); }); it("keeps focus on start field", () => { @@ -1695,7 +1690,7 @@ describe("", () => { }); it("sets selection to [null, ] on click", () => { - assertInputTextsEqual(root, "", DATE_CONFIG.str); + assertInputValuesEqual(root, "", DATE_CONFIG.str); }); it("moves focus to start field", () => { @@ -1709,7 +1704,7 @@ describe("", () => { }); it("shows [null, ] in input fields", () => { - assertInputTextsEqual(root, "", SELECTED_RANGE[1].str); + assertInputValuesEqual(root, "", SELECTED_RANGE[1].str); }); it("keeps focus on end field", () => { @@ -1726,7 +1721,7 @@ describe("", () => { }); it("shows [null, null] in input fields", () => { - assertInputTextsEqual(root, "", ""); + assertInputValuesEqual(root, "", ""); }); it("keeps focus on end field", () => { @@ -1739,7 +1734,7 @@ describe("", () => { }); it("sets selection to [null, null] on click", () => { - assertInputTextsEqual(root, "", ""); + assertInputValuesEqual(root, "", ""); }); it("moves focus to start field", () => { @@ -1753,7 +1748,7 @@ describe("", () => { }); it("shows [null, ] in input fields", () => { - assertInputTextsEqual(root, "", SELECTED_RANGE[1].str); + assertInputValuesEqual(root, "", SELECTED_RANGE[1].str); }); it("keeps focus on end field", () => { @@ -1784,7 +1779,7 @@ describe("", () => { }); it("shows [, ] in input fields", () => { - assertInputTextsEqual(root, DATE_CONFIG.str, SELECTED_RANGE[1].str); + assertInputValuesEqual(root, DATE_CONFIG.str, SELECTED_RANGE[1].str); }); it("keeps focus on start field", () => { @@ -1797,7 +1792,7 @@ describe("", () => { }); it("sets selection to [, ]", () => { - assertInputTextsEqual(root, DATE_CONFIG.str, SELECTED_RANGE[1].str); + assertInputValuesEqual(root, DATE_CONFIG.str, SELECTED_RANGE[1].str); }); it("keeps focus on start field", () => { @@ -1811,7 +1806,7 @@ describe("", () => { }); it("shows [, ] in input fields", () => { - assertInputTextsEqual(root, SELECTED_RANGE[0].str, SELECTED_RANGE[1].str); + assertInputValuesEqual(root, SELECTED_RANGE[0].str, SELECTED_RANGE[1].str); }); it("keeps focus on start field", () => { @@ -1828,7 +1823,7 @@ describe("", () => { }); it("shows [, ] in input fields", () => { - assertInputTextsEqual(root, DATE_CONFIG.str, SELECTED_RANGE[1].str); + assertInputValuesEqual(root, DATE_CONFIG.str, SELECTED_RANGE[1].str); }); it("keeps focus on start field", () => { @@ -1841,7 +1836,7 @@ describe("", () => { }); it("sets selection to [, ]", () => { - assertInputTextsEqual(root, DATE_CONFIG.str, SELECTED_RANGE[1].str); + assertInputValuesEqual(root, DATE_CONFIG.str, SELECTED_RANGE[1].str); }); it("keeps focus on start field", () => { @@ -1855,7 +1850,7 @@ describe("", () => { }); it("shows [, ] in input fields", () => { - assertInputTextsEqual(root, SELECTED_RANGE[0].str, SELECTED_RANGE[1].str); + assertInputValuesEqual(root, SELECTED_RANGE[0].str, SELECTED_RANGE[1].str); }); it("keeps focus on start field", () => { @@ -1872,7 +1867,7 @@ describe("", () => { }); it("shows [, null] in input fields", () => { - assertInputTextsEqual(root, DATE_CONFIG.str, ""); + assertInputValuesEqual(root, DATE_CONFIG.str, ""); }); it("keeps focus on start field", () => { @@ -1885,7 +1880,7 @@ describe("", () => { }); it("sets selection to [, null]", () => { - assertInputTextsEqual(root, DATE_CONFIG.str, ""); + assertInputValuesEqual(root, DATE_CONFIG.str, ""); }); it("moves focus to end field", () => { @@ -1899,7 +1894,7 @@ describe("", () => { }); it("shows [, ] in input fields", () => { - assertInputTextsEqual(root, SELECTED_RANGE[0].str, SELECTED_RANGE[1].str); + assertInputValuesEqual(root, SELECTED_RANGE[0].str, SELECTED_RANGE[1].str); }); it("keeps focus on start field", () => { @@ -1916,7 +1911,7 @@ describe("", () => { }); it("shows [null, ] in input fields", () => { - assertInputTextsEqual(root, "", SELECTED_RANGE[1].str); + assertInputValuesEqual(root, "", SELECTED_RANGE[1].str); }); it("keeps focus on start field", () => { @@ -1929,7 +1924,7 @@ describe("", () => { }); it("sets selection to [null, ]", () => { - assertInputTextsEqual(root, "", SELECTED_RANGE[1].str); + assertInputValuesEqual(root, "", SELECTED_RANGE[1].str); }); it("keep focus on start field", () => { @@ -1943,7 +1938,7 @@ describe("", () => { }); it("shows [, ] in input fields", () => { - assertInputTextsEqual(root, SELECTED_RANGE[0].str, SELECTED_RANGE[1].str); + assertInputValuesEqual(root, SELECTED_RANGE[0].str, SELECTED_RANGE[1].str); }); it("keeps focus on start field", () => { @@ -1960,7 +1955,7 @@ describe("", () => { }); it("shows [, null] in input fields", () => { - assertInputTextsEqual(root, SELECTED_RANGE[0].str, ""); + assertInputValuesEqual(root, SELECTED_RANGE[0].str, ""); }); it("moves focus to end field", () => { @@ -1973,7 +1968,7 @@ describe("", () => { }); it("sets selection to [, null]", () => { - assertInputTextsEqual(root, SELECTED_RANGE[0].str, ""); + assertInputValuesEqual(root, SELECTED_RANGE[0].str, ""); }); it("keeps focus on end field", () => { @@ -1987,7 +1982,7 @@ describe("", () => { }); it("shows [, ] in input fields", () => { - assertInputTextsEqual(root, SELECTED_RANGE[0].str, SELECTED_RANGE[1].str); + assertInputValuesEqual(root, SELECTED_RANGE[0].str, SELECTED_RANGE[1].str); }); it("moves focus back to start field", () => { @@ -2010,7 +2005,7 @@ describe("", () => { }); it("shows [null, ] in input fields", () => { - assertInputTextsEqual(root, "", DATE_CONFIG.str); + assertInputValuesEqual(root, "", DATE_CONFIG.str); }); it("keeps focus on end field", () => { @@ -2023,7 +2018,7 @@ describe("", () => { }); it("sets selection to [null, ]", () => { - assertInputTextsEqual(root, "", DATE_CONFIG.str); + assertInputValuesEqual(root, "", DATE_CONFIG.str); }); it("moves focus to start field", () => { @@ -2037,7 +2032,7 @@ describe("", () => { }); it("shows [, ] in input fields", () => { - assertInputTextsEqual(root, SELECTED_RANGE[0].str, SELECTED_RANGE[1].str); + assertInputValuesEqual(root, SELECTED_RANGE[0].str, SELECTED_RANGE[1].str); }); it("keeps focus on end field", () => { @@ -2054,7 +2049,7 @@ describe("", () => { }); it("shows [, ] in input fields", () => { - assertInputTextsEqual(root, SELECTED_RANGE[0].str, DATE_CONFIG.str); + assertInputValuesEqual(root, SELECTED_RANGE[0].str, DATE_CONFIG.str); }); it("keeps focus on end field", () => { @@ -2067,7 +2062,7 @@ describe("", () => { }); it("sets selection to [, ]", () => { - assertInputTextsEqual(root, SELECTED_RANGE[0].str, DATE_CONFIG.str); + assertInputValuesEqual(root, SELECTED_RANGE[0].str, DATE_CONFIG.str); }); it("keeps focus on end field", () => { @@ -2081,7 +2076,7 @@ describe("", () => { }); it("shows [, ] in input fields", () => { - assertInputTextsEqual(root, SELECTED_RANGE[0].str, SELECTED_RANGE[1].str); + assertInputValuesEqual(root, SELECTED_RANGE[0].str, SELECTED_RANGE[1].str); }); it("keeps focus on end field", () => { @@ -2098,7 +2093,7 @@ describe("", () => { }); it("shows [, ] in input fields", () => { - assertInputTextsEqual(root, SELECTED_RANGE[0].str, DATE_CONFIG.str); + assertInputValuesEqual(root, SELECTED_RANGE[0].str, DATE_CONFIG.str); }); it("keeps focus on end field", () => { @@ -2111,7 +2106,7 @@ describe("", () => { }); it("sets selection to [, ]", () => { - assertInputTextsEqual(root, SELECTED_RANGE[0].str, DATE_CONFIG.str); + assertInputValuesEqual(root, SELECTED_RANGE[0].str, DATE_CONFIG.str); }); it("keeps focus on end field", () => { @@ -2125,7 +2120,7 @@ describe("", () => { }); it("shows [, ] in input fields", () => { - assertInputTextsEqual(root, SELECTED_RANGE[0].str, SELECTED_RANGE[1].str); + assertInputValuesEqual(root, SELECTED_RANGE[0].str, SELECTED_RANGE[1].str); }); it("keeps focus on end field", () => { @@ -2142,7 +2137,7 @@ describe("", () => { }); it("shows [null, ] in input fields", () => { - assertInputTextsEqual(root, "", SELECTED_RANGE[1].str); + assertInputValuesEqual(root, "", SELECTED_RANGE[1].str); }); it("moves focus to start field", () => { @@ -2155,7 +2150,7 @@ describe("", () => { }); it("sets selection to [null, ]", () => { - assertInputTextsEqual(root, "", SELECTED_RANGE[1].str); + assertInputValuesEqual(root, "", SELECTED_RANGE[1].str); }); it("keeps focus on start field", () => { @@ -2169,7 +2164,7 @@ describe("", () => { }); it("shows [, ] in input fields", () => { - assertInputTextsEqual(root, SELECTED_RANGE[0].str, SELECTED_RANGE[1].str); + assertInputValuesEqual(root, SELECTED_RANGE[0].str, SELECTED_RANGE[1].str); }); it("moves focus back to end field", () => { @@ -2186,7 +2181,7 @@ describe("", () => { }); it("shows [, null] in input fields", () => { - assertInputTextsEqual(root, SELECTED_RANGE[0].str, ""); + assertInputValuesEqual(root, SELECTED_RANGE[0].str, ""); }); it("keeps focus on end field", () => { @@ -2199,7 +2194,7 @@ describe("", () => { }); it("sets selection to [, null]", () => { - assertInputTextsEqual(root, SELECTED_RANGE[0].str, ""); + assertInputValuesEqual(root, SELECTED_RANGE[0].str, ""); }); it("keeps focus on end field", () => { @@ -2213,7 +2208,7 @@ describe("", () => { }); it("shows [, ] in input fields", () => { - assertInputTextsEqual(root, SELECTED_RANGE[0].str, SELECTED_RANGE[1].str); + assertInputValuesEqual(root, SELECTED_RANGE[0].str, SELECTED_RANGE[1].str); }); it("keeps focus on end field", () => { @@ -2235,7 +2230,7 @@ describe("", () => { getStartInput(root).simulate("focus"); getDayElement(START_DAY).simulate("click"); - assertInputTextsEqual(root, "", ""); + assertInputValuesEqual(root, "", ""); expect(onChange.called).to.be.true; expect(onChange.calledWith([null, null])).to.be.true; }); @@ -2249,7 +2244,7 @@ describe("", () => { changeInputText(startInput, ""); expect(onChange.called).to.be.true; assertDateRangesEqual(onChange.getCall(0).args[0], [null, END_STR]); - assertInputTextsEqual(root, "", END_STR); + assertInputValuesEqual(root, "", END_STR); }); it("Clearing the dates in both inputs invokes onChange with [null, null] and leaves the inputs empty", () => { @@ -2261,39 +2256,39 @@ describe("", () => { changeStartInputText(root, ""); expect(onChange.called).to.be.true; assertDateRangesEqual(onChange.getCall(0).args[0], [null, null]); - assertInputTextsEqual(root, "", ""); + assertInputValuesEqual(root, "", ""); }); }); describe("when controlled", () => { it("Setting value causes defaultValue to be ignored", () => { const { root } = wrap(); - assertInputTextsEqual(root, START_STR, END_STR); + assertInputValuesEqual(root, START_STR, END_STR); }); it("Setting value to [undefined, undefined] shows empty fields", () => { const { root } = wrap(); - assertInputTextsEqual(root, "", ""); + assertInputValuesEqual(root, "", ""); }); it("Setting value to [null, null] shows empty fields", () => { const { root } = wrap(); - assertInputTextsEqual(root, "", ""); + assertInputValuesEqual(root, "", ""); }); it("Shows empty start field and formatted date in end field when value is [null, ]", () => { const { root } = wrap(); - assertInputTextsEqual(root, "", END_STR); + assertInputValuesEqual(root, "", END_STR); }); it("Shows empty end field and formatted date in start field when value is [, null]", () => { const { root } = wrap(); - assertInputTextsEqual(root, START_STR, ""); + assertInputValuesEqual(root, START_STR, ""); }); it("Shows formatted dates in both fields when value is [, ]", () => { const { root } = wrap(); - assertInputTextsEqual(root, START_STR, END_STR); + assertInputValuesEqual(root, START_STR, END_STR); }); it("Updating value changes the text accordingly in both fields", () => { @@ -2302,7 +2297,7 @@ describe("", () => { root.update(); root.setProps({ value: DATE_RANGE_2 }); root.update(); - assertInputTextsEqual(root, START_STR_2, END_STR_2); + assertInputValuesEqual(root, START_STR_2, END_STR_2); }); it("Pressing Enter saves the inputted date and closes the popover", () => { @@ -2342,7 +2337,7 @@ describe("", () => { getStartInput(root).simulate("focus"); // to open popover getDayElement(START_DAY).simulate("click"); assertDateRangesEqual(onChange.getCall(0).args[0], [null, END_STR]); - assertInputTextsEqual(root, "", END_STR); + assertInputValuesEqual(root, "", END_STR); expect(onChange.callCount).to.equal(1); }); @@ -2353,13 +2348,13 @@ describe("", () => { changeStartInputText(root, START_STR_2); expect(onChange.callCount).to.equal(1); assertDateRangesEqual(onChange.getCall(0).args[0], [START_STR_2, END_STR]); - assertInputTextsEqual(root, START_STR, END_STR); + assertInputValuesEqual(root, START_STR, END_STR); // since the component is controlled, value changes don't persist across onChanges changeEndInputText(root, END_STR_2); expect(onChange.callCount).to.equal(2); assertDateRangesEqual(onChange.getCall(1).args[0], [START_STR, END_STR_2]); - assertInputTextsEqual(root, START_STR, END_STR); + assertInputValuesEqual(root, START_STR, END_STR); }); it("Clicking a start date causes focus to move to end field", () => { @@ -2390,7 +2385,7 @@ describe("", () => { getStartInput(root).simulate("focus"); getDayElement(1).simulate("mouseenter"); changeStartInputText(root, START_STR_2); - assertInputTextsEqual(root, START_STR_2, ""); + assertInputValuesEqual(root, START_STR_2, ""); }); describe("Typing an out-of-range date", () => { @@ -2577,7 +2572,7 @@ describe("", () => { getDayElement(START_DAY).simulate("click"); assertDateRangesEqual(onChange.getCall(0).args[0], [null, null]); - assertInputTextsEqual(root, "", ""); + assertInputValuesEqual(root, "", ""); }); it(`Clearing only the start input (e.g.) invokes onChange with [null, ], doesn't clear the\ @@ -2593,14 +2588,14 @@ describe("", () => { changeInputText(startInput, ""); expect(onChange.calledOnce).to.be.true; assertDateRangesEqual(onChange.getCall(0).args[0], [null, END_STR]); - assertInputTextsEqual(root, "", END_STR); + assertInputValuesEqual(root, "", END_STR); // start day should still be selected in the calendar, ignoring user's typing expect(getDayElement(START_DAY).hasClass(DateClasses.DATEPICKER_DAY_SELECTED)).to.be.true; // blurring should put the controlled start date back in the start input, overriding user's typing startInput.simulate("blur"); - assertInputTextsEqual(root, START_STR, END_STR); + assertInputValuesEqual(root, START_STR, END_STR); }); it(`Clearing the inputs invokes onChange with [null, null], doesn't clear the selected dates, and\ @@ -2616,17 +2611,17 @@ describe("", () => { changeInputText(startInput, ""); expect(onChange.calledOnce).to.be.true; assertDateRangesEqual(onChange.getCall(0).args[0], [null, null]); - assertInputTextsEqual(root, "", ""); + assertInputValuesEqual(root, "", ""); expect(getDayElement(START_DAY).hasClass(DateClasses.DATEPICKER_DAY_SELECTED)).to.be.true; startInput.simulate("blur"); - assertInputTextsEqual(root, START_STR, ""); + assertInputValuesEqual(root, START_STR, ""); }); it.skip("Formats locale-specific format strings properly", () => { const { root } = wrap(); - assertInputTextsEqual(root, START_DE_STR_2, END_DE_STR_2); + assertInputValuesEqual(root, START_DE_STR_2, END_DE_STR_2); }); }); @@ -2638,10 +2633,6 @@ describe("", () => { return root.find(InputGroup).last().find("input") as WrappedComponentInput; } - function getInputText(input: WrappedComponentInput) { - return input.props().value; - } - function getInputPlaceholderText(input: WrappedComponentInput) { return input.prop("placeholder"); } @@ -2676,13 +2667,13 @@ describe("", () => { expect(isEndInputFocused(root)).to.be.true; } - function assertInputTextsEqual(root: WrappedComponentRoot, startInputText: string, endInputText: string) { - assertInputTextEquals(getStartInput(root), startInputText); - assertInputTextEquals(getEndInput(root), endInputText); + function assertInputValuesEqual(root: WrappedComponentRoot, startInputValue: string, endInputValue: string) { + assertInputValueEquals(getStartInput(root), startInputValue); + assertInputValueEquals(getEndInput(root), endInputValue); } - function assertInputTextEquals(input: WrappedComponentInput, inputText: string) { - expect(getInputText(input)).to.equal(inputText); + function assertInputValueEquals(input: WrappedComponentInput, inputValue: string) { + expect(input.closest(InputGroup).prop("value")).to.equal(inputValue); } function assertDateRangesEqual(actual: DateRange, expected: string[]) { diff --git a/packages/docs-app/src/examples/core-examples/inputGroupExample.tsx b/packages/docs-app/src/examples/core-examples/inputGroupExample.tsx index 5a798bfd50..1cc00ec261 100644 --- a/packages/docs-app/src/examples/core-examples/inputGroupExample.tsx +++ b/packages/docs-app/src/examples/core-examples/inputGroupExample.tsx @@ -55,7 +55,9 @@ export class InputGroupExample extends React.PureComponent this.setState({ disabled })); private handleLargeChange = handleBooleanChange(large => this.setState({ large, ...(large && { small: false }) })); private handleSmallChange = handleBooleanChange(small => this.setState({ small, ...(small && { large: false }) })); - private handleFilterChange = handleStringChange(filterValue => this.setState({ filterValue })); + private handleFilterChange = handleStringChange(filterValue => + window.setTimeout(() => this.setState({ filterValue }), 10), + ); private handleTagChange = handleStringChange(tagValue => this.setState({ tagValue })); public render() { @@ -96,16 +98,18 @@ export class InputGroupExample extends React.PureComponent - + + +