fix: set min-width instead of width (#15547)

* fix: set min-width instead of width

* test: updte snapshots
This commit is contained in:
DiamondYuan 2019-03-21 11:31:58 +08:00 committed by 偏右
parent c8a326643d
commit 4eb33eb149
4 changed files with 13 additions and 12 deletions

View File

@ -348,7 +348,7 @@ exports[`renders ./components/date-picker/demo/disabled-date.md correctly 1`] =
<div>
<span
class="ant-calendar-picker"
style="width:195px"
style="min-width:195px"
>
<div>
<input
@ -493,7 +493,7 @@ exports[`renders ./components/date-picker/demo/extra-footer.md correctly 1`] = `
</span>
<span
class="ant-calendar-picker"
style="width:195px"
style="min-width:195px"
>
<div>
<input
@ -872,7 +872,7 @@ exports[`renders ./components/date-picker/demo/mode.md correctly 1`] = `
<div>
<span
class="ant-calendar-picker"
style="width:195px"
style="min-width:195px"
>
<div>
<input
@ -1264,7 +1264,7 @@ exports[`renders ./components/date-picker/demo/start-end.md correctly 1`] = `
<div>
<span
class="ant-calendar-picker"
style="width:195px"
style="min-width:195px"
>
<div>
<input
@ -1295,7 +1295,7 @@ exports[`renders ./components/date-picker/demo/start-end.md correctly 1`] = `
</span>
<span
class="ant-calendar-picker"
style="width:195px"
style="min-width:195px"
>
<div>
<input
@ -1567,7 +1567,7 @@ exports[`renders ./components/date-picker/demo/time.md correctly 1`] = `
<div>
<span
class="ant-calendar-picker"
style="width:195px"
style="min-width:195px"
>
<div>
<input

View File

@ -1029,7 +1029,7 @@ exports[`Picker format by locale date 1`] = `
exports[`Picker format by locale dateTime 1`] = `
<span
class="ant-calendar-picker"
style="width: 195px;"
style="min-width: 195px;"
>
<div>
<input

View File

@ -34,7 +34,7 @@ export default function createPicker(TheCalendar: React.ComponentClass): any {
static getDerivedStateFromProps(nextProps: PickerProps, prevState: PickerState) {
const state: Partial<PickerState> = {};
let open: boolean = prevState.open;
let { open } = prevState;
if ('open' in nextProps) {
state.open = nextProps.open;
@ -53,6 +53,7 @@ export default function createPicker(TheCalendar: React.ComponentClass): any {
}
private input: any;
private prefixCls?: string;
constructor(props: any) {
@ -92,7 +93,7 @@ export default function createPicker(TheCalendar: React.ComponentClass): any {
};
handleChange = (value: moment.Moment | null) => {
const props = this.props;
const { props } = this;
if (!('value' in props)) {
this.setState({
value,
@ -155,13 +156,13 @@ export default function createPicker(TheCalendar: React.ComponentClass): any {
let pickerProps: Object = {};
let calendarProps: any = {};
const pickerStyle: { width?: number } = {};
const pickerStyle: { minWidth?: number } = {};
if (props.showTime) {
calendarProps = {
// fix https://github.com/ant-design/ant-design/issues/1902
onSelect: this.handleChange,
};
pickerStyle.width = 195;
pickerStyle.minWidth = 195;
} else {
pickerProps = {
onChange: this.handleChange,

View File

@ -2550,7 +2550,7 @@ exports[`renders ./components/form/demo/time-related-controls.md correctly 1`] =
<span
class="ant-calendar-picker"
id="time_related_controls_date-time-picker"
style="width:195px"
style="min-width:195px"
>
<div>
<input