Skip to content

Commit

Permalink
Merge pull request #1720 from kaliber5/loose-open-modal-arg
Browse files Browse the repository at this point in the history
Accept loosely typed values for modal `@open`
  • Loading branch information
simonihmig committed Jan 8, 2022
2 parents b7eb9c7 + 13fa68d commit f4de798
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion addon/components/bs-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ export default class Modal extends Component {

@action
handleVisibilityChanges() {
if (this.args.open !== false) {
if (this.open) {
this.show();
} else {
this.hide();
Expand Down
20 changes: 20 additions & 0 deletions tests/integration/components/bs-modal-simple-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,26 @@ module('Integration | Component | bs-modal-simple', function (hooks) {
assert.dom('.modal').doesNotExist('Modal is hidden');
});

// https://github.com/kaliber5/ember-bootstrap/issues/1612
test('open property accepts loosely types values', async function (assert) {
this.set('open', null);
await render(
hbs`<BsModalSimple @title="Simple Dialog" @fade={{false}} @open={{this.open}}>Hello world!</BsModalSimple>`
);

assert.dom('.modal').doesNotExist('Modal is hidden');

this.set('open', '');
await settled();
assert.dom('.modal').doesNotExist('Modal is hidden');

this.set('open', {});
await settled();

assert.dom('.modal').hasClass(visibilityClass(), 'Modal is visible');
assert.dom('.modal').isVisible();
});

testRequiringTransitions('open property shows modal [fade]', async function (assert) {
this.set('open', false);
await render(hbs`<BsModalSimple @title="Simple Dialog" @open={{this.open}}>Hello world!</BsModalSimple>`);
Expand Down

0 comments on commit f4de798

Please sign in to comment.