Skip to content

Commit

Permalink
make menu item support href
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelcobain committed Dec 15, 2017
1 parent 630f803 commit 1dcd802
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions addon/components/paper-menu-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Ember from 'ember';
import layout from '../templates/components/paper-menu-item';
import ChildMixin from 'ember-paper/mixins/child-mixin';

const { Component } = Ember;
const { Component, computed } = Ember;

/**
* @class PaperMenuItem
Expand All @@ -17,16 +17,18 @@ export default Component.extend(ChildMixin, {
tagName: 'md-menu-item',
disabled: false,

shouldRenderButton: computed.or('onClick', 'href'),

actions: {
handleClick(event) {
this.get('dropdown.actions').close();
this.sendAction('onClick', event);
}
},

mouseEnter() {
if (!this.get('disabled')) {
this.$('button').focus();
}
}

});
4 changes: 2 additions & 2 deletions addon/templates/components/paper-menu-item.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{#if onClick}}
{{#paper-button onClick="handleClick" disabled=disabled}}
{{#if shouldRenderButton}}
{{#paper-button onClick="handleClick" href=href target=target disabled=disabled}}
{{yield}}
{{/paper-button}}
{{else}}
Expand Down

0 comments on commit 1dcd802

Please sign in to comment.