Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for displaying multiple modals at the same time #476

Merged
merged 3 commits into from
Mar 12, 2024
Merged
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
2 changes: 1 addition & 1 deletion addon/components/au-modal.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default class AuModal extends Component {

<template>
{{#if @modalOpen}}
{{#in-element this.destinationElement}}
{{#in-element this.destinationElement insertBefore=null}}
<div class="au-c-modal-backdrop {{if @modalOpen 'is-visible'}}"></div>
<div
id="{{@id}}"
Expand Down
6 changes: 5 additions & 1 deletion styles/components/_c-modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
========================================================================== */

$au-modal-z-index: 9999 !default;
$au-modal-backdrop-z-index: 9998 !default;
$au-modal-backdrop-z-index: $au-modal-z-index !default;

@if $au-modal-z-index != $au-modal-backdrop-z-index {
@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.";
}

/* Component
========================================================================== */
Expand Down
15 changes: 15 additions & 0 deletions tests/integration/components/au-modal-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,4 +248,19 @@ module('Integration | Component | au-modal', function (hooks) {
await click(closeButton);
assert.strictEqual(timesCalled, 1);
});

test('it can render multiple modals at once', async function (assert) {
await render(hbs`
<AuModalContainer />
<AuModal @modalOpen={{true}}>
<div data-test-content-one>One!</div>
</AuModal>
<AuModal @modalOpen={{true}}>
<div data-test-content-two>Two!</div>
</AuModal>
`);

assert.dom('[data-test-content-one]').containsText('One!');
assert.dom('[data-test-content-two]').containsText('Two!');
});
});
Loading