Skip to content

Commit

Permalink
Dropdown close cancellation fixed for wrapped date picker
Browse files Browse the repository at this point in the history
  • Loading branch information
tomivirkki committed May 9, 2016
1 parent 0240e19 commit 75f300c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 7 deletions.
51 changes: 45 additions & 6 deletions test/dropdown.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
<head>
<meta charset="utf-8">
<script src="../../web-component-tester/browser.js"></script>

<script src="../../iron-test-helpers/mock-interactions.js"></script>
<link rel="import" href="../vaadin-date-picker.html">
<script src="common.js"></script>
<script>
HTMLImports.whenReady(function() {
Polymer({
is: 'vaadin-date-picker-wrapper'
});
});
</script>
</head>

<body>
Expand All @@ -17,6 +24,18 @@
</template>
</test-fixture>

<test-fixture id="datepicker-wrapped">
<template>
<vaadin-date-picker-wrapper></vaadin-date-picker-wrapper>
</template>
</test-fixture>

<dom-module id="vaadin-date-picker-wrapper">
<template>
<vaadin-date-picker id="datepicker" label="foo"></vaadin-date-picker>
</template>
</dom-module>

<script>
describe('Dropdown', function() {
var datepicker;
Expand All @@ -31,12 +50,9 @@
datepicker.async(done, 1);
});

it('should not close on calendar icon mousedown', function(done) {
it('should not close on calendar icon down', function(done) {
datepicker.addEventListener('iron-overlay-opened', function() {
Polymer.Base.fire('mousedown', {}, {
bubbles: true,
node: datepicker.$.calendar
});
MockInteractions.down(datepicker.$.calendar);
expect(datepicker.$.dropdown.opened).to.be.true;

done();
Expand Down Expand Up @@ -119,6 +135,29 @@

});
});

describe('Dropdown-wrapped', function() {
var datepicker;

beforeEach(function() {
datepicker = fixture('datepicker-wrapped').$.datepicker;
});

afterEach(function(done) {
datepicker.async(done, 1);
});

it('should not close on calendar icon down', function(done) {
datepicker.addEventListener('iron-overlay-opened', function() {
MockInteractions.down(datepicker.$.calendar);
expect(datepicker.$.dropdown.opened).to.be.true;

done();
});
datepicker.open();
});

});
</script>

</body>
Expand Down
3 changes: 2 additions & 1 deletion vaadin-date-picker.html
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,8 @@
},

_preventCancelOnComponentAccess: function(e) {
if (/tap|mousedown|touchstart/.test(e.detail.type) && this.contains(e.detail.target)) {
var event = Polymer.dom(e.detail);
if (/tap|mousedown|touchstart/.test(e.detail.type) && event.path.indexOf(this) > -1) {
e.preventDefault();
}
},
Expand Down

0 comments on commit 75f300c

Please sign in to comment.