Skip to content

Commit

Permalink
Fixes problems with input event overriding
Browse files Browse the repository at this point in the history
  • Loading branch information
arqex committed Oct 19, 2018
1 parent 6596acb commit b8af389
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 23 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,8 @@
Changelog
=========
## 2.16.1
* Fixes input event overriding

## 2.16.0
* The prop `disableOnClickOutside` has been renamed to `disableCloseOnClickOutside`
* The calendar doesn't get closed an open when clicking in the input anymore.
Expand Down
20 changes: 11 additions & 9 deletions DateTime.js
Expand Up @@ -463,15 +463,17 @@ var Datetime = createClass({
children = [];

if ( this.props.input ) {
var finalInputProps = assign({
type: 'text',
className: 'form-control',
onClick: this.overrideEvent( 'onClick', this.openCalendar ),
onFocus: this.overrideEvent( 'onFocus', this.openCalendar ),
onChange: this.overrideEvent( 'onChange', this.onInputChange ),
onKeyDown: this.overrideEvent( 'onKeyDown', this.onInputKey ),
value: this.state.inputValue,
}, this.props.inputProps);
var finalInputProps = assign(
{ type: 'text', className: 'form-control', value: this.state.inputValue },
this.props.inputProps,
{
onClick: this.overrideEvent( 'onClick', this.openCalendar ),
onFocus: this.overrideEvent( 'onFocus', this.openCalendar ),
onChange: this.overrideEvent( 'onChange', this.onInputChange ),
onKeyDown: this.overrideEvent( 'onKeyDown', this.onInputKey ),
}
);

if ( this.props.renderInput ) {
children = [ React.createElement('div', { key: 'i' }, this.props.renderInput( finalInputProps, this.openCalendar, this.closeCalendar )) ];
} else {
Expand Down
22 changes: 12 additions & 10 deletions dist/react-datetime.js
@@ -1,5 +1,5 @@
/*
react-datetime v2.16.0
react-datetime v2.16.1
https://github.com/YouCanBookMe/react-datetime
MIT: https://github.com/YouCanBookMe/react-datetime/raw/master/LICENSE
*/
Expand Down Expand Up @@ -524,15 +524,17 @@ return /******/ (function(modules) { // webpackBootstrap
children = [];

if ( this.props.input ) {
var finalInputProps = assign({
type: 'text',
className: 'form-control',
onClick: this.overrideEvent( 'onClick', this.openCalendar ),
onFocus: this.overrideEvent( 'onFocus', this.openCalendar ),
onChange: this.overrideEvent( 'onChange', this.onInputChange ),
onKeyDown: this.overrideEvent( 'onKeyDown', this.onInputKey ),
value: this.state.inputValue,
}, this.props.inputProps);
var finalInputProps = assign(
{ type: 'text', className: 'form-control', value: this.state.inputValue },
this.props.inputProps,
{
onClick: this.overrideEvent( 'onClick', this.openCalendar ),
onFocus: this.overrideEvent( 'onFocus', this.openCalendar ),
onChange: this.overrideEvent( 'onChange', this.onInputChange ),
onKeyDown: this.overrideEvent( 'onKeyDown', this.onInputKey ),
}
);

if ( this.props.renderInput ) {
children = [ React.createElement('div', { key: 'i' }, this.props.renderInput( finalInputProps, this.openCalendar, this.closeCalendar )) ];
} else {
Expand Down
4 changes: 2 additions & 2 deletions dist/react-datetime.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/react-datetime.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "react-datetime",
"version": "2.16.0",
"version": "2.16.1",
"description": "A lightweight but complete datetime picker React.js component",
"homepage": "https://github.com/YouCanBookMe/react-datetime",
"repository": {
Expand Down

0 comments on commit b8af389

Please sign in to comment.