Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1464 from metasfresh/dev-1429
Browse files Browse the repository at this point in the history
Prevent propagation of keydown event from Datetime #1429
  • Loading branch information
metas-mk committed Jan 10, 2018
2 parents 270cb7a + 4a44667 commit 531ade5
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions src/components/widget/DatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ import { connect } from "react-redux";

import { addNotification } from "../../actions/AppActions";

const propTypes = {
dispatch: PropTypes.func.isRequired,
handleBackdropLock: PropTypes.func,
patch: PropTypes.func,
field: PropTypes.string,
value: PropTypes.any
};

class DatePicker extends Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -59,6 +67,10 @@ class DatePicker extends Component {
this.handleClose();
};

handleKeydown = e => {
e.stopPropagation();
};

renderDay = (props, currentDate) => {
return (
<td {...props} onDoubleClick={() => this.handleClose()}>
Expand All @@ -75,20 +87,20 @@ class DatePicker extends Component {

render() {
return (
<Datetime
closeOnTab={true}
renderDay={this.renderDay}
renderInput={this.renderInput}
onBlur={this.handleBlur}
onFocus={this.handleFocus}
{...this.props}
/>
<div tabIndex="-1" onKeyDown={this.handleKeydown}>
<Datetime
closeOnTab={true}
renderDay={this.renderDay}
renderInput={this.renderInput}
onBlur={this.handleBlur}
onFocus={this.handleFocus}
{...this.props}
/>
</div>
);
}
}

DatePicker.propTypes = {
dispatch: PropTypes.func.isRequired
};
DatePicker.propTypes = propTypes;

export default connect()(DatePicker);

0 comments on commit 531ade5

Please sign in to comment.