diff --git a/README.md b/README.md index 61a90926..dacf7f57 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ![Download count all time](https://img.shields.io/npm/dt/ember-attacher.svg) [![npm](https://img.shields.io/npm/dm/ember-attacher.svg)]() [![Ember Observer Score](http://emberobserver.com/badges/ember-attacher.svg)](http://emberobserver.com/addons/ember-attacher) -[![Build Status](https://travis-ci.org/kybishop/ember-attacher.svg)](https://travis-ci.org/kybishop/ember-attacher) +[![Build Status](https://travis-ci.org/kybishop/ember-attacher.svg?branch=master)](https://travis-ci.org/kybishop/ember-attacher) Tooltips and popovers made easy. Just drop an `{{#attach-tooltip}} or `{{#attach-popover}}` in a parent and your popper is ready to go! diff --git a/addon/components/attach-popover.js b/addon/components/attach-popover.js index 38868826..9e14a4af 100644 --- a/addon/components/attach-popover.js +++ b/addon/components/attach-popover.js @@ -93,7 +93,9 @@ export default Component.extend({ }), _hideOn: computed('hideOn', function() { - return this.get('hideOn').split(' '); + const hideOn = this.get('hideOn'); + + return hideOn === null ? [] : (hideOn || DEFAULTS.hideOn).split(' '); }), _modifiers: computed('arrow', 'flip', 'modifiers', function() { @@ -146,12 +148,14 @@ export default Component.extend({ } }, - _shouldRender: computed('lazyRender', function() { + _shouldRender: computed.not('lazyRender', function() { return !this.get('lazyRender'); }), _showOn: computed('showOn', function() { - return this.get('showOn').split(' '); + const showOn = this.get('showOn'); + + return showOn === null ? [] : (showOn || DEFAULTS.showOn).split(' '); }), _transitionDuration: 0, diff --git a/tests/integration/components/ember-attacher/is-shown-test.js b/tests/integration/components/ember-attacher/is-shown-test.js index 01688f35..ef8ca47a 100644 --- a/tests/integration/components/ember-attacher/is-shown-test.js +++ b/tests/integration/components/ember-attacher/is-shown-test.js @@ -36,7 +36,7 @@ test('isShown works with showOn/hideOn set to "click"', async function(assert) { assert.equal(isVisible(attachment), true, 'Shown again after click'); }); -test('isShown works with showOn/hideOn set to "none"', async function(assert) { +test('isShown works with showOn/hideOn set to `null`', async function(assert) { assert.expect(3); this.on('closePopover', () => { @@ -49,14 +49,17 @@ test('isShown works with showOn/hideOn set to "none"', async function(assert) { this.set('isShown', false); + this.set('hideOn', null); + this.set('showOn', null); + this.render(hbs` + `); + + const attachment = find('#attachment'); + + assert.equal(isVisible(attachment), false, 'Initially hidden'); + + await triggerEvent('#target', 'mouseenter'); + + assert.equal(isVisible(attachment), true, 'Now shown'); + + await click('#target'); + + assert.equal(isVisible(attachment), false, 'Hidden again'); + + await triggerEvent('#target', 'focus'); + + assert.equal(isVisible(attachment), true, 'Shown again'); +}); + +test('sets showOn to an empty array when passed `null`', async function(assert) { + assert.expect(3); + + this.set('showOn', null); + + this.render(hbs` + + `); + + const attachment = find('#attachment'); + + assert.equal(isVisible(attachment), false, 'Initially hidden'); + + await triggerEvent('#target', 'mouseenter'); + + assert.equal(isVisible(attachment), false, 'Still hidden after mouseenter'); + + await triggerEvent('#target', 'focus'); + + assert.equal(isVisible(attachment), false, 'Still hidden after focus'); +}); \ No newline at end of file