Skip to content

Commit

Permalink
Fix DatePicker[showTime] default width
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Dec 11, 2016
1 parent 86a2cf3 commit b912f1c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
37 changes: 23 additions & 14 deletions components/date-picker/RangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import moment from 'moment';
import RangeCalendar from 'rc-calendar/lib/RangeCalendar';
import RcDatePicker from 'rc-calendar/lib/Picker';
import classNames from 'classnames';
import assign from 'object-assign';
import Icon from '../icon';

export default class RangePicker extends React.Component<any, any> {
Expand Down Expand Up @@ -144,6 +145,12 @@ export default class RangePicker extends React.Component<any, any> {
/>
);

// default width for showTime
const pickerStyle = {} as any;
if (props.showTime) {
pickerStyle.minWidth = 300;
}

const clearIcon = (!props.disabled && props.allowClear && state.value && (state.value[0] || state.value[1]))
? <Icon
type="cross-circle"
Expand Down Expand Up @@ -177,19 +184,21 @@ export default class RangePicker extends React.Component<any, any> {
);
};

return (<span className={props.pickerClass} style={style}>
<RcDatePicker
{...props}
{...pickerChangeHandler}
calendar={calendar}
value={state.value}
open={state.open}
onOpenChange={this.handleOpenChange}
prefixCls={`${prefixCls}-picker-container`}
style={popupStyle}
>
{input}
</RcDatePicker>
</span>);
return (
<span className={props.pickerClass} style={assign({}, style, pickerStyle)}>
<RcDatePicker
{...props}
{...pickerChangeHandler}
calendar={calendar}
value={state.value}
open={state.open}
onOpenChange={this.handleOpenChange}
prefixCls={`${prefixCls}-picker-container`}
style={popupStyle}
>
{input}
</RcDatePicker>
</span>
);
}
}
9 changes: 8 additions & 1 deletion components/date-picker/createPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import MonthCalendar from 'rc-calendar/lib/MonthCalendar';
import RcDatePicker from 'rc-calendar/lib/Picker';
import classNames from 'classnames';
import omit from 'omit.js';
import assign from 'object-assign';
import Icon from '../icon';

export interface PickerProps {
Expand Down Expand Up @@ -135,6 +136,12 @@ export default function createPicker(TheCalendar) {
/>
);

// default width for showTime
const pickerStyle = {} as any;
if (props.showTime) {
pickerStyle.minWidth = 154;
}

const clearIcon = (!props.disabled && props.allowClear && this.state.value) ?
<Icon
type="cross-circle"
Expand All @@ -157,7 +164,7 @@ export default function createPicker(TheCalendar) {
);

return (
<span className={props.pickerClass} style={props.style}>
<span className={props.pickerClass} style={assign({}, props.style, pickerStyle)}>
<RcDatePicker
{...props}
{...pickerChangeHandler}
Expand Down

0 comments on commit b912f1c

Please sign in to comment.