Skip to content

Commit

Permalink
add "closeOnSelect" attribute to DatePicker
Browse files Browse the repository at this point in the history
  • Loading branch information
thg303 committed Aug 10, 2017
1 parent e7dd109 commit f194e0d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 11 additions & 0 deletions examples/src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ export default class App extends Component {
<DatePicker />
</Example>
</div>
<div>
<Example
title="ورودی تاریخ ساده بسته شدن خودکار"
code={basicAutoDatePickerCode}>
<DatePicker closeOnSelect/>
</Example>
</div>
<div>
<Example
title="ورود تاریخ کنترل شده"
Expand Down Expand Up @@ -119,6 +126,10 @@ const basicDatePickerCode = `render() {
return <DatePicker />;
}`;

const basicAutoDatePickerCode = `render() {
return <DatePicker closeOnSelect/>;
}`;


const clearDatePickerCode = `render() {
return (
Expand Down
7 changes: 5 additions & 2 deletions src/components/DatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ export default class DatePicker extends Component {
removable: PropTypes.bool,
timePickerComponent: PropTypes.func,
calendarStyles: PropTypes.object,
calendarContainerProps: PropTypes.object
calendarContainerProps: PropTypes.object,
closeOnSelect: PropTypes.bool
};

static defaultProps = {
inputFormat: 'jYYYY/jM/jD',
calendarStyles: require('../styles/basic.css'),
calendarContainerProps: {}
calendarContainerProps: {},
closeOnSelect: false
};

state = {
Expand Down Expand Up @@ -98,6 +100,7 @@ export default class DatePicker extends Component {
}

this.setMomentValue(momentValue);
this.setState({isOpen: !this.props.closeOnSelect})
}

handleInputChange(event) {
Expand Down

0 comments on commit f194e0d

Please sign in to comment.