Simon Egersand
2017-11-01 689227efa649efc14117929a316bb3962cd7af7b
Pass event to onFocus event handler
2 files modified
8 ■■■■ changed files
DateTime.js 6 ●●●● patch | view | raw | blame | history
README.md 2 ●●● patch | view | raw | blame | history
DateTime.js
@@ -351,10 +351,10 @@
        this.props.onChange( date );
    },
    openCalendar: function() {
        if (!this.state.open) {
    openCalendar: function( e ) {
        if ( !this.state.open ) {
            this.setState({ open: true }, function() {
                this.props.onFocus();
                this.props.onFocus( e );
            });
        }
    },
README.md
@@ -50,7 +50,7 @@
| **locale** | `string` | `null` | Manually set the locale for the react-datetime instance. Moment.js locale needs to be loaded to be used, see [i18n docs](#i18n).
| **utc** | `boolean` | `false` | When true, input time values will be interpreted as UTC (Zulu time) by Moment.js. Otherwise they will default to the user's local timezone.
| **onChange** | `function` | empty function | Callback trigger when the date changes. The callback receives the selected `moment` object as only parameter, if the date in the input is valid. If the date in the input is not valid, the callback receives the value of the input (a string). |
| **onFocus** | `function` | empty function | Callback trigger for when the user opens the datepicker. |
| **onFocus** | `function` | empty function | Callback trigger for when the user opens the datepicker. The callback receives an event of type SyntheticEvent. |
| **onBlur** | `function` | empty function | Callback trigger for when the user clicks outside of the input, simulating a regular onBlur. The callback receives the selected `moment` object as only parameter, if the date in the input is valid. If the date in the input is not valid, the callback returned. |
| **onViewModeChange** | `function` | empty function | Callback trigger when the view mode changes. The callback receives the selected view mode string (`years`, `months`, `days` or `time`) as only parameter.|
| **viewMode** | `string` or `number` | `'days'` | The default view to display when the picker is shown (`'years'`, `'months'`, `'days'`, `'time'`). |