Skip to content

Commit

Permalink
Merge pull request #147 from bigblind/master
Browse files Browse the repository at this point in the history
Use arrows (without alt) to go through date ranges. Thanks @bigblind!
  • Loading branch information
dannyvankooten authored Oct 5, 2018
2 parents c9b95fa + 181bee7 commit 8515ba6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions assets/src/js/components/DatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ class DatePicker extends Component {

@bind
handleKeyPress(evt) {
if( ! evt.altKey ) {
// Don't handle input when the user is in a text field or text area.
let tag = event.target.tagName;
if(tag === "INPUT" || tag === "TEXTAREA") {
return;
}

Expand All @@ -171,14 +173,14 @@ class DatePicker extends Component {
let newStartDate, newEndDate;

switch(evt.keyCode) {
// ALT + left-arrow
// left-arrow
case 37:
newStartDate = new Date(+this.state.startDate - diff)
newEndDate = new Date(+this.state.endDate - diff)
this.setDateRange(newStartDate, newEndDate)
break;

// ALT + right-arrow
//right-arrow
case 39:
newStartDate = new Date(+this.state.startDate + diff)
newEndDate = new Date(+this.state.endDate + diff)
Expand Down
2 changes: 1 addition & 1 deletion assets/src/js/pages/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Dashboard extends Component {
</div>

<div class="footer hide-on-mobile">
<p>Use <strong>ALT + arrow-key</strong> to cycle through date ranges.</p>
<p>Use <strong>the arrow keys</strong> to cycle through date ranges.</p>
</div>
</section>

Expand Down

0 comments on commit 8515ba6

Please sign in to comment.