Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DateInput] Add support for datepicker clearButtonText and todayButtonText props. #3020

Merged
merged 2 commits into from
Oct 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/datetime/src/dateInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ export interface IDateInputProps extends IDatePickerBaseProps, IDateFormatProps,
*/
canClearSelection?: boolean;

/**
* Text for the reset button in the date picker action bar.
* Passed to `DatePicker` component.
* @default "Clear"
*/
clearButtonText?: string;

/**
* Whether the calendar popover should close when a date is selected.
* @default true
Expand Down Expand Up @@ -108,6 +115,13 @@ export interface IDateInputProps extends IDatePickerBaseProps, IDateFormatProps,
* in the input field, pass `new Date(undefined)` to the value prop.
*/
value?: Date | null;

/**
* Text for the today button in the date picker action bar.
* Passed to `DatePicker` component.
* @default "Today"
*/
todayButtonText?: string;
}

export interface IDateInputState {
Expand Down
17 changes: 16 additions & 1 deletion packages/datetime/test/dateInputTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as sinon from "sinon";

import { Classes as CoreClasses, InputGroup, Intent, Keys, Popover, Position } from "@blueprintjs/core";
import { Months } from "../src/common/months";
import { Classes, DateInput, IDateInputProps, TimePicker, TimePrecision } from "../src/index";
import { Classes, DateInput, DatePicker, IDateInputProps, TimePicker, TimePrecision } from "../src/index";
import { DATE_FORMAT } from "./common/dateFormat";
import * as DateTestUtils from "./common/dateTestUtils";

Expand Down Expand Up @@ -201,6 +201,21 @@ describe("<DateInput>", () => {
assert.equal(timePicker.prop("disabled"), true);
});

it("clearButtonText and todayButtonText props are passed to DatePicker", () => {
const datePickerProps = {
clearButtonText: "clear",
todayButtonText: "today",
};

const wrapper = mount(<DateInput {...DATE_FORMAT} {...datePickerProps} />).setState({
isOpen: true,
});
const datePicker = wrapper.find(DatePicker);

assert.equal(datePicker.prop("clearButtonText"), "clear");
assert.equal(datePicker.prop("todayButtonText"), "today");
});

it("inputProps are passed to InputGroup", () => {
const inputRef = sinon.spy();
const onFocus = sinon.spy();
Expand Down