Skip to content

Commit bee460b

Browse files
committed
add "closeOnSelect" attribute to DatePicker
1 parent 1aff540 commit bee460b

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

examples/src/components/App.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ export default class App extends Component {
4848
<DatePicker />
4949
</Example>
5050
</div>
51+
<div>
52+
<Example
53+
title="ورودی تاریخ ساده بسته شدن خودکار"
54+
code={basicAutoDatePickerCode}>
55+
<DatePicker closeOnSelect/>
56+
</Example>
57+
</div>
5158
<div>
5259
<Example
5360
title="ورود تاریخ کنترل شده"
@@ -119,6 +126,10 @@ const basicDatePickerCode = `render() {
119126
return <DatePicker />;
120127
}`;
121128

129+
const basicAutoDatePickerCode = `render() {
130+
return <DatePicker closeOnSelect/>;
131+
}`;
132+
122133

123134
const clearDatePickerCode = `render() {
124135
return (

src/components/DatePicker.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ export default class DatePicker extends Component {
2222
removable: PropTypes.bool,
2323
timePickerComponent: PropTypes.func,
2424
calendarStyles: PropTypes.object,
25-
calendarContainerProps: PropTypes.object
25+
calendarContainerProps: PropTypes.object,
26+
closeOnSelect: PropTypes.bool
2627
};
2728

2829
static defaultProps = {
2930
inputFormat: 'jYYYY/jM/jD',
3031
calendarStyles: require('../styles/basic.css'),
31-
calendarContainerProps: {}
32+
calendarContainerProps: {},
33+
closeOnSelect: false
3234
};
3335

3436
state = {
@@ -99,6 +101,7 @@ export default class DatePicker extends Component {
99101
}
100102

101103
this.setMomentValue(momentValue);
104+
this.setState({isOpen: !this.props.closeOnSelect})
102105
}
103106

104107
handleInputChange(event) {

0 commit comments

Comments
 (0)