Skip to content
This repository has been archived by the owner on May 15, 2023. It is now read-only.

Commit

Permalink
Advance to year field when / is pressed
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelli committed Apr 18, 2016
1 parent 3e6cb12 commit a395409
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"homepage": "https://github.com/PolymerElements/gold-cc-expiration-input",
"ignore": [],
"dependencies": {
"iron-a11y-keys-behavior": "PolymerElements/iron-a11y-keys-behavior#^1.1.2",
"iron-validator-behavior": "PolymerElements/iron-validator-behavior#^1.0.0",
"iron-validatable-behavior": "PolymerElements/iron-validatable-behavior#^1.0.0",
"iron-flex-layout": "PolymerElements/iron-flex-layout#^1.0.0",
Expand Down
12 changes: 12 additions & 0 deletions date-input.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-a11y-keys-behavior/iron-a11y-keys-behavior.html">
<link rel="import" href="../iron-input/iron-input.html">
<link rel="import" href="../iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="../iron-validatable-behavior/iron-validatable-behavior.html">
Expand Down Expand Up @@ -96,6 +97,7 @@
is: 'date-input',

behaviors: [
Polymer.IronA11yKeysBehavior,
Polymer.IronValidatableBehavior
],

Expand Down Expand Up @@ -174,6 +176,16 @@
'_computeDate(month,year)'
],

keyBindings: {
'a': '_selectYear',
'@': '_selectYear',
'/': '_selectYear'
},

_selectYear: function() {
this.$.expirationYear.focus();
},

_computeDate: function(month, year) {
// Months are 0-11.
this.date = {month: month, year: year};
Expand Down
10 changes: 10 additions & 0 deletions test/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@
assert.equal(year.getAttribute('aria-labelledby'), label + ' yearLabel');
});

test('/ key advances', function() {
var input = fixture('basic');
var dateInput = input.$$('.paper-input-input');
var month = dateInput.$$('input:nth-of-type(1)');
var year = dateInput.$$('input:nth-of-type(2)');
MockInteractions.focus(input.inputElement);
assert.isTrue(input.focused);
debugger;
});

});


Expand Down

0 comments on commit a395409

Please sign in to comment.