fix(overlays): return promises for toggle open and close methods

This commit is contained in:
Joren Broekema 2020-12-07 13:11:06 +01:00
parent de536282e1
commit 11e8dbcbfe
3 changed files with 13 additions and 6 deletions

View file

@ -0,0 +1,5 @@
---
'@lion/overlays': patch
---
Return promises for the OverlayMixin toggle, open and close methods, since the OverlayController hiding/showing is asynchronous.

View file

@ -325,22 +325,22 @@ export const OverlayMixinImplementation = superclass =>
/** /**
* Toggles the overlay * Toggles the overlay
*/ */
toggle() { async toggle() {
/** @type {OverlayController} */ (this._overlayCtrl).toggle(); await /** @type {OverlayController} */ (this._overlayCtrl).toggle();
} }
/** /**
* Shows the overlay * Shows the overlay
*/ */
open() { async open() {
/** @type {OverlayController} */ (this._overlayCtrl).show(); await /** @type {OverlayController} */ (this._overlayCtrl).show();
} }
/** /**
* Hides the overlay * Hides the overlay
*/ */
close() { async close() {
/** @type {OverlayController} */ (this._overlayCtrl).hide(); await /** @type {OverlayController} */ (this._overlayCtrl).hide();
} }
}; };
export const OverlayMixin = dedupeMixin(OverlayMixinImplementation); export const OverlayMixin = dedupeMixin(OverlayMixinImplementation);

View file

@ -920,9 +920,11 @@ describe('OverlayController', () => {
expect(ctrl2.content).to.be.displayed; expect(ctrl2.content).to.be.displayed;
await ctrl3.show(); await ctrl3.show();
await ctrl3._showComplete;
expect(ctrl3.content).to.be.displayed; expect(ctrl3.content).to.be.displayed;
await ctrl2.hide(); await ctrl2.hide();
await ctrl2._hideComplete;
expect(ctrl0.content).to.be.displayed; expect(ctrl0.content).to.be.displayed;
expect(ctrl1.content).to.be.displayed; expect(ctrl1.content).to.be.displayed;