Skip to content

Commit

Permalink
fix(multi-select): prevent close emit twice (#1414)
Browse files Browse the repository at this point in the history
  • Loading branch information
vt-allianz authored and GitHub Enterprise committed Jan 9, 2025
1 parent 831c04e commit 8a75b24
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,10 @@ export class NxMultiSelectComponent<S, T> implements ControlValueAccessor, NxFor
}

_close() {
if (!this._isOpen) {
return;
}

this._isOpen = false;
this.openedChange.emit(false);
this._updateTooltipText();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,13 @@ describe('NxMultiSelectComponent', () => {

describe('and clicking the backdrop', () => {
beforeEach(async () => {
spyOn(multiSelectInstance.openedChange, 'emit');
await multiSelectHarness.clickBackdrop();
});

it('closes the panel', async () => {
expect(await multiSelectHarness.isOpen()).toBeFalse();
expect(multiSelectInstance.openedChange.emit).toHaveBeenCalledOnceWith(false);
});
});
});
Expand Down Expand Up @@ -600,21 +602,25 @@ describe('NxMultiSelectComponent', () => {

describe('and closing using ESC', () => {
beforeEach(async () => {
spyOn(multiSelectInstance.openedChange, 'emit');
await multiSelectHarness.closeWithEsc();
});

it('is closed', async () => {
expect(await multiSelectHarness.isOpen()).toBeFalse();
expect(multiSelectInstance.openedChange.emit).toHaveBeenCalledOnceWith(false);
});
});

describe('and tabing out', () => {
beforeEach(async () => {
spyOn(multiSelectInstance.openedChange, 'emit');
await multiSelectHarness.pressKey('Tab', TAB);
});

it('is closed', async () => {
expect(await multiSelectHarness.isOpen()).toBeFalse();
expect(multiSelectInstance.openedChange.emit).toHaveBeenCalledOnceWith(false);
});
});
});
Expand Down

0 comments on commit 8a75b24

Please sign in to comment.