Skip to content

Commit 15a1ccd

Browse files
authored
Merge pull request #476 from Rahien/karel/fix-modal-v3
Add support for displaying multiple modals at the same time
2 parents a513a4c + 4046458 commit 15a1ccd

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

addon/components/au-modal.gjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export default class AuModal extends Component {
8585

8686
<template>
8787
{{#if @modalOpen}}
88-
{{#in-element this.destinationElement}}
88+
{{#in-element this.destinationElement insertBefore=null}}
8989
<div class="au-c-modal-backdrop {{if @modalOpen 'is-visible'}}"></div>
9090
<div
9191
id="{{@id}}"

styles/components/_c-modal.scss

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
========================================================================== */
77

88
$au-modal-z-index: 9999 !default;
9-
$au-modal-backdrop-z-index: 9998 !default;
9+
$au-modal-backdrop-z-index: $au-modal-z-index !default;
10+
11+
@if $au-modal-z-index != $au-modal-backdrop-z-index {
12+
@warn "DEPRECATED $au-modal-backdrop-z-index. This property has been deprecated and $au-modal-z-index and $au-modal-backdrop-z-index have different values. This will result in unexpected behavior when showing multiple modals.";
13+
}
1014

1115
/* Component
1216
========================================================================== */

tests/integration/components/au-modal-test.js

+15
Original file line numberDiff line numberDiff line change
@@ -248,4 +248,19 @@ module('Integration | Component | au-modal', function (hooks) {
248248
await click(closeButton);
249249
assert.strictEqual(timesCalled, 1);
250250
});
251+
252+
test('it can render multiple modals at once', async function (assert) {
253+
await render(hbs`
254+
<AuModalContainer />
255+
<AuModal @modalOpen={{true}}>
256+
<div data-test-content-one>One!</div>
257+
</AuModal>
258+
<AuModal @modalOpen={{true}}>
259+
<div data-test-content-two>Two!</div>
260+
</AuModal>
261+
`);
262+
263+
assert.dom('[data-test-content-one]').containsText('One!');
264+
assert.dom('[data-test-content-two]').containsText('Two!');
265+
});
251266
});

0 commit comments

Comments
 (0)