Skip to content

Commit

Permalink
fix: 修改value和panelValue的变化
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaox2025f committed Feb 3, 2021
1 parent 7e18fe6 commit 03c7e48
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 70 deletions.
6 changes: 3 additions & 3 deletions demo/demolist/Demo13.js
Expand Up @@ -17,22 +17,22 @@ class Demo13 extends Component {
state = {
datePickerPanelValue: '2004-05-09',
rangePickerPanelValues: '2014-01-02',
dateValue: '2020-02-03',
// dateValue: '2020-02-03',
// rangeValue: ['2098-09-02', '2099-08-06']
}
onSelect = d => {
console.log(d);
}
onDateChange = (d) => {
this.setState({
datePickerPanelValue: null,
// datePickerPanelValue: null,
dateValue: d
})
};
onRangeChange = (d) => {
this.setState({
rangeValue: d,
rangePickerPanelValues: null
// rangePickerPanelValues: null
})
};
render() {
Expand Down
2 changes: 1 addition & 1 deletion demo/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/demo.css.map

Large diffs are not rendered by default.

125 changes: 65 additions & 60 deletions dist/demo.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/demo.js.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/DatePicker.js
Expand Up @@ -63,7 +63,7 @@ class DatePicker extends Component {
}
if ("panelValue" in nextProps) {
this.setState({
panelValue: value ? null : nextProps.panelValue
panelValue: value ? null : moment(nextProps.panelValue)
});
}
if ("open" in nextProps) {
Expand Down Expand Up @@ -273,7 +273,8 @@ class DatePicker extends Component {
e.stopPropagation();
this.setState({
inputValue:'',
value:''
value:'',
panelValue: null
})
this.fireChange('','');
}
Expand Down
6 changes: 4 additions & 2 deletions src/RangePicker.js
Expand Up @@ -51,11 +51,12 @@ if (cn) {
class RangePicker extends Component {
constructor(props, context) {
super(props, context);
const initialValue = props.value || props.defaultValue
this.state = {
hoverValue: [],
value: this.initValue(props),
open: props.open||false,
panelValues: (props.value || props.defaultValue) ? null : this.modifyPanelValues(props.panelValues)
panelValues: (initialValue && initialValue.length) ? null : this.modifyPanelValues(props.panelValues)
};
}
modifyPanelValues = values => {
Expand Down Expand Up @@ -108,8 +109,9 @@ class RangePicker extends Component {
});
}
if ("panelValues" in nextProps) {
const isValueEmpty = !value.some(item => item)
this.setState({
panelValues: value ? null : this.modifyPanelValues(nextProps.panelValues)
panelValues: !isValueEmpty ? null : this.modifyPanelValues(nextProps.panelValues)
});
}
if ("open" in nextProps) {
Expand Down

0 comments on commit 03c7e48

Please sign in to comment.