Skip to content

Commit

Permalink
Merge efc1c44 into 47ab901
Browse files Browse the repository at this point in the history
  • Loading branch information
manolo committed Aug 1, 2018
2 parents 47ab901 + efc1c44 commit a63213f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 7 deletions.
8 changes: 1 addition & 7 deletions src/vaadin-time-picker.html
Original file line number Diff line number Diff line change
Expand Up @@ -293,16 +293,10 @@

const stepResolution = this.__validDayDivisor(this.step) && this.step || 60;

if (!this.step || stepResolution >= 15 * 60) {
return;
}

if (Polymer.IronA11yKeysBehavior.keyboardEventMatchesKeys(e, 'down')) {
this.__onArrowPressWithStep(-stepResolution);
} else if (Polymer.IronA11yKeysBehavior.keyboardEventMatchesKeys(e, 'up')) {
this.__onArrowPressWithStep(stepResolution);
} else if (Polymer.IronA11yKeysBehavior.keyboardEventMatchesKeys(e, 'esc')) {
this.__memoValue = this.value && this.__validateTime(this.i18n.parseTime(this.value));
}
}

Expand Down Expand Up @@ -487,7 +481,7 @@
* Focusable element used by vaadin-control-state-mixin
*/
get focusElement() {
return this.__inputElement || this;
return this.__inputElement;
}

/**
Expand Down
14 changes: 14 additions & 0 deletions test/input-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@
timePicker = fixture('default');
});

describe('element', () => {
it('should have a valid localName', () => {
expect(timePicker.localName).to.be.equal('vaadin-time-picker');
});

it('should be registered in Vaadin namespace', () => {
expect(Vaadin.TimePickerElement.is).to.be.equal('vaadin-time-picker');
});

it('should have a valid version', () => {
expect(Vaadin.TimePickerElement.version).to.be.ok;
});
});

it('vaadin-time-picker-text-field should exist', () => {
expect(timePicker.__inputElement.localName).to.be.equal('vaadin-time-picker-text-field');
});
Expand Down
12 changes: 12 additions & 0 deletions test/keyboard-navigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
MockInteractions.pressAndReleaseKeyOn(getInput(), 40);
}

function escape() {
MockInteractions.pressAndReleaseKeyOn(timePicker.__dropdownElement, 27);
}

function getInput() {
return timePicker.__inputElement;
}
Expand Down Expand Up @@ -228,6 +232,14 @@
arrowUp();
expect(document.querySelector('vaadin-combo-box-overlay')).not.to.be.ok;
});

it('should not change value on escape', () => {
timePicker.step = 0.5;
arrowUp();
expect(timePicker.__inputElement.value).to.be.equal('00:00:00.500');
escape();
expect(timePicker.__inputElement.value).to.be.equal('');
});
});
});
</script>
Expand Down
15 changes: 15 additions & 0 deletions test/step-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@
expect(timePicker.step).to.be.equal(undefined);
});

it('should have dropdown items if step is undefined', () => {
timePicker.step = undefined;
expect(timePicker.__dropdownItems.length).to.be.equal(24);
});

it('should have dropdown items if step is bigger or equal than 15min', () => {
timePicker.step = 15 * 60;
expect(timePicker.__dropdownItems.length).to.be.equal(96);
});

it('should not have dropdown items if step is lesser than 15min', () => {
timePicker.step = 15 * 60 - 1;
expect(timePicker.__dropdownItems.length).to.be.equal(0);
});

it('should allow setting valid step property value', () => {
timePicker.step = 0.5;
expect(timePicker.step).to.be.equal(0.5);
Expand Down

0 comments on commit a63213f

Please sign in to comment.