Skip to content
This repository was archived by the owner on Dec 19, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion paper-menu-button.html
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,10 @@
},

listeners: {
'iron-select': '_onIronSelect'
'iron-select': '_onIronSelect',
'iron-overlay-opened': '__stopEventPropagation',
'iron-overlay-closed': '__stopEventPropagation',
'iron-overlay-canceled': '__stopEventPropagation'
},

/**
Expand Down Expand Up @@ -412,6 +415,10 @@
if (path.indexOf(trigger) > -1) {
event.preventDefault();
}
},

__stopEventPropagation: function(event) {
event.stopPropagation();
}
});

Expand Down
41 changes: 39 additions & 2 deletions test/paper-menu-button.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
MockInteractions.tap(trigger);
});
});

MockInteractions.tap(trigger);
});

Expand All @@ -107,6 +107,43 @@
expect(menuButton.hasAttribute('aria-haspopup')).to.be.equal(true);
});

test('iron-overlay-opened event propagation is stopped', function(done) {
var spy = sinon.stub();
Polymer.dom(menuButton).parentNode.addEventListener('iron-overlay-opened', spy);
menuButton.opened = true;
Polymer.Base.async(function() {
expect(spy.called).to.be.false;
done();
}, 10);
});

test('iron-overlay-closed event propagation is stopped', function(done) {
var spy = sinon.stub();
Polymer.dom(menuButton).parentNode.addEventListener('iron-overlay-closed', spy);
menuButton.opened = true;
Polymer.Base.async(function() {
menuButton.opened = false;
Polymer.Base.async(function() {
expect(spy.called).to.be.false;
done();
}, 10);
}, 10);
});

test('iron-overlay-canceled event propagation is stopped', function(done) {
var spy = sinon.stub();
Polymer.dom(menuButton).parentNode.addEventListener('iron-overlay-canceled', spy);
menuButton.opened = true;
Polymer.Base.async(function() {
// Will cause cancel to happen
MockInteractions.tap(menuButton);
Polymer.Base.async(function() {
expect(spy.called).to.be.false;
done();
}, 10);
}, 10);
});

});

suite('when there are two buttons', function() {
Expand Down Expand Up @@ -150,7 +187,7 @@
Polymer.Base.async(function() {
MockInteractions.tap(otherTrigger);
});


Polymer.Base.async(function() {
expect(firstClosed).to.be.equal(true);
Expand Down