Skip to content

Commit

Permalink
Select first input on clicking the wrapper
Browse files Browse the repository at this point in the history
Closes #114
  • Loading branch information
wojtekmaj committed Nov 12, 2018
1 parent b1cdad0 commit a244d4d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/DateInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,14 @@ export default class DateInput extends PureComponent {
return getValueType(maxDetail);
}

onClick = (event) => {
if (event.target === event.currentTarget) {
// Wrapper was directly clicked
const [/* nativeInput */, firstInput] = event.target.children;
focus(firstInput);
}
}

onKeyDown = (event) => {
switch (event.key) {
case 'ArrowLeft': {
Expand Down Expand Up @@ -481,7 +489,10 @@ export default class DateInput extends PureComponent {
const { className } = this.props;

return (
<div className={className}>
<div
className={className}
onClick={this.onClick}
>
{this.renderNativeInput()}
{this.renderCustomInputs()}
</div>
Expand Down

0 comments on commit a244d4d

Please sign in to comment.