Skip to content

Commit

Permalink
fix: mode of rangePicker is array
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Nov 30, 2019
1 parent 2b1678d commit ce62257
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/RangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
DisabledTimes,
DisabledTime,
PickerMode,
PanelMode,
} from './interface';
import { toArray } from './utils/miscUtil';
import RangeContext from './RangeContext';
Expand Down Expand Up @@ -45,6 +46,7 @@ export interface RangePickerSharedProps<DateType> {
separator?: React.ReactNode;
allowEmpty?: [boolean, boolean];
selectable?: [boolean, boolean];
mode?: [PanelMode, PanelMode];
onChange?: (
value: RangeValue<DateType>,
formatString: [string, string],
Expand All @@ -68,6 +70,7 @@ type OmitPickerProps<Props> = Omit<
| 'disabledTime'
| 'showToday'
| 'showTime'
| 'mode'
>;

export interface RangePickerBaseProps<DateType>
Expand Down Expand Up @@ -116,6 +119,7 @@ function InternalRangePicker<DateType>(
defaultValue,
defaultPickerValue,
separator = '~',
mode,
picker,
pickerRef,
locale,
Expand Down Expand Up @@ -331,6 +335,7 @@ function InternalRangePicker<DateType>(
placeholder={placeholder && placeholder[0]}
defaultPickerValue={defaultPickerValue && defaultPickerValue[0]}
{...{ disabledTime: disabledStartTime, showTime: startShowTime }} // Fix ts define
mode={mode && mode[0]}
disabled={disabled || mergedSelectable[0] === false}
disabledDate={disabledStartDate}
onChange={date => {
Expand All @@ -348,6 +353,7 @@ function InternalRangePicker<DateType>(
placeholder={placeholder && placeholder[1]}
defaultPickerValue={defaultPickerValue && defaultPickerValue[1]}
{...{ disabledTime: disabledEndTime, showTime: endShowTime }} // Fix ts define
mode={mode && mode[1]}
disabled={disabled || mergedSelectable[1] === false}
disabledDate={disabledEndDate}
onChange={date => {
Expand Down
9 changes: 9 additions & 0 deletions tests/range.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -447,4 +447,13 @@ describe('Range', () => {
matchValues(wrapper, '1990-09-13 01:02:03', '1990-09-23 05:06:07');
});
});

it('mode is array', () => {
const wrapper = mount(<MomentRangePicker mode={['year', 'month']} />);
wrapper.openPicker();
expect(wrapper.find('.rc-picker-year-panel')).toHaveLength(1);

wrapper.openPicker(1);
expect(wrapper.find('.rc-picker-month-panel')).toHaveLength(1);
});
});

1 comment on commit ce62257

@vercel
Copy link

@vercel vercel bot commented on ce62257 Nov 30, 2019

Choose a reason for hiding this comment

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

Please sign in to comment.