Skip to content

Commit

Permalink
disabled today select time (react-component#640)
Browse files Browse the repository at this point in the history
Co-authored-by: veveue <[email protected]>
  • Loading branch information
Veveue and Veveue authored Mar 13, 2020
1 parent f68ef71 commit 3365215
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
16 changes: 16 additions & 0 deletions examples/antd-calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,22 @@ export default () => (
renderFooter={mode => <span>{mode} extra footer</span>}
/>
</div>
<div style={{ margin: 10 }}>
<p>disabled today select time</p>
<Calendar
showWeekNumber={false}
locale={cn ? zhCN : enUS}
defaultValue={now}
showToday
format={getFormat(true)}
showOk={false}
timePicker={timePickerElement}
onChange={onStandaloneChange}
disabledDate={current => current && current <= moment()}
onSelect={onStandaloneSelect}
renderFooter={mode => <span>{mode} extra footer</span>}
/>
</div>
<div style={{ float: 'left', width: 300 }}>
<Demo defaultValue={now} />
</div>
Expand Down
1 change: 1 addition & 0 deletions src/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ class Calendar extends React.Component<CalendarProps, CalendarState> {
showDateInput={props.showDateInput}
timePicker={timePicker}
selectedValue={selectedValue}
timePickerDisabled={!selectedValue}
value={value}
disabledDate={disabledDate}
okDisabled={
Expand Down
6 changes: 3 additions & 3 deletions tests/Calendar.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ describe('Calendar', () => {
});
it('timePicker date have no changes when hover', () => {
const timePicker = <TimePickerPanel defaultValue={moment('00:00:00', 'HH:mm:ss')} />;
const wrapper = mount(<Calendar timePicker={timePicker} />);
const wrapper = mount(
<Calendar defaultSelectedValue={moment('01:01:01', 'HH:mm:ss')} timePicker={timePicker} />,
);
wrapper.find('.rc-calendar-time-picker-btn').simulate('click');
const dateBtns = wrapper.find('.rc-calendar-my-select a');
const btnClassName = 'rc-calendar-time-status';
Expand Down Expand Up @@ -165,8 +167,6 @@ describe('Calendar', () => {
}
const wrapper = mount(<ControlledCalendar />);

wrapper.find('.rc-calendar-time-picker-btn').simulate('click');
expect(wrapper.find('.rc-calendar-time-picker').length).toBe(1);
wrapper.find('.rc-calendar-time-picker-btn').simulate('click');
expect(wrapper.find('.rc-calendar-time-picker').length).toBe(0);

Expand Down

0 comments on commit 3365215

Please sign in to comment.