Skip to content
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
4 changes: 2 additions & 2 deletions addon/components/o-s-s/side-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export default class OssSidePanel extends Component<OssSidePanelArgs> {
}

@action
onClickOutside(_: any, event: Event): void {
const sidePanelElement = document.querySelector('.oss-side-panel');
onClickOutside(backdrop: HTMLElement, event: Event): void {
const sidePanelElement = backdrop.closest('.oss-side-panel');
if (sidePanelElement?.contains(event.target as Node)) return;

if (event.target === this.initialTarget) {
Expand Down
1 change: 1 addition & 0 deletions app/styles/molecules/button-dropdown.less
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
min-width: 180px;
border: 1px solid var(--color-border-default);
border-radius: var(--border-radius-sm);
overflow: hidden;
z-index: 99;

&--visible {
Expand Down
1 change: 1 addition & 0 deletions app/styles/organisms/sidebar.less
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ a.oss-sidebar-item {

&:not(&--expanded) &__items-container--visible {
.box-shadow-md;
border: 1px solid var(--color-border-default);
position: absolute;
top: 0;
left: calc(var(--sidebar-width) - var(--spacing-px-3));
Expand Down
37 changes: 36 additions & 1 deletion tests/integration/components/o-s-s/side-panel-test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { hbs } from 'ember-cli-htmlbars';
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { click, render } from '@ember/test-helpers';
import { click, render, type TestContext } from '@ember/test-helpers';
import sinon from 'sinon';

module('Integration | Component | o-s-s/side-panel', function (hooks) {
Expand Down Expand Up @@ -168,4 +168,39 @@ module('Integration | Component | o-s-s/side-panel', function (hooks) {
assert.ok(this.onClose.calledOnce, 'Clicked on the transparent backdrop so the side panel closes.');
});
});

module('When two side panels are mounted', (hooks) => {
hooks.beforeEach(function (this: TestContext) {
this.onCloseFirst = sinon.stub();
this.onCloseSecond = sinon.stub();
});

async function renderSidePanels() {
await render(
hbs`
<div data-control-name="outside-side-panels"></div>
<OSS::SidePanel @visible={{true}} @backdrop={{true}} @onClose={{this.onCloseFirst}} />
<OSS::SidePanel @visible={{true}} @backdrop={{true}} @onClose={{this.onCloseSecond}}>
<:main>
<div data-control-name="second-side-panel-content"></div>
</:main>
</OSS::SidePanel>`
);
}

test('Clicking inside the second side panel does not close it', async function (this: TestContext, assert) {
await renderSidePanels();
await click('[data-control-name="second-side-panel-content"]');

assert.true(this.onCloseSecond.notCalled);
});

test('Clicking outside both side panels closes them', async function (this: TestContext, assert) {
await renderSidePanels();
await click('[data-control-name="outside-side-panels"]');

assert.true(this.onCloseFirst.calledOnceWithExactly());
assert.true(this.onCloseSecond.calledOnceWithExactly());
});
});
});
Loading