Skip to content

Commit

Permalink
Fix RangePicker input (#9009)
Browse files Browse the repository at this point in the history
  • Loading branch information
yesmeck committed Jan 31, 2018
1 parent 99469bd commit 842c7f2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions components/date-picker/RangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ export default class RangePicker extends React.Component<any, RangePickerState>

handleHoverChange = (hoverValue: any) => this.setState({ hoverValue });

handleCalendarInputSelect = (value: RangePickerValue) => {
this.setState(({ showDate }) => ({
value,
showDate: getShowDateFromValue(value) || showDate,
}));
}

setValue(value: RangePickerValue, hidePanel?: boolean) {
this.handleChange(value);
if ((hidePanel || !this.props.showTime) && !('open' in this.props)) {
Expand Down Expand Up @@ -263,6 +270,7 @@ export default class RangePicker extends React.Component<any, RangePickerState>
onHoverChange={this.handleHoverChange}
onPanelChange={props.onPanelChange}
showToday={showToday}
onInputSelect={this.handleCalendarInputSelect}
/>
);

Expand Down
9 changes: 9 additions & 0 deletions components/date-picker/__tests__/RangePicker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,13 @@ describe('RangePicker', () => {
).toBe(true);
resetMockDate();
});

// https://github.com/ant-design/ant-design/issues/6999
it('input date manually', () => {
const wrapper = mount(<RangePicker open />);
const dateString = '2008-12-31';
const input = wrapper.find('.ant-calendar-input').first();
input.simulate('change', { target: { value: dateString } });
expect(input.getDOMNode().value).toBe(dateString);
});
});

0 comments on commit 842c7f2

Please sign in to comment.