Skip to content

Commit

Permalink
[DateInput] Add support for datepicker clearButtonText and todayButto…
Browse files Browse the repository at this point in the history
…nText props. (#3020)

* [DateInput] Add datepicker clearButtonText and todayButtonText props support.

* [DateInput] Add unit test for clearButtonText and todayButtonText props.
  • Loading branch information
rfbotto authored and giladgray committed Oct 15, 2018
1 parent ac38072 commit 9f89f66
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
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

1 comment on commit 9f89f66

@blueprint-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Previews: documentation | landing | table

Please sign in to comment.