Merge pull request #794 from ing-bank/fix/overlayCatchRejectedPromise
fix(overlays): only teardown when overlayCtrl defined
This commit is contained in:
commit
29d740c87d
3 changed files with 25 additions and 14 deletions
|
|
@ -304,9 +304,14 @@ export const FormGroupMixin = dedupeMixin(
|
|||
_anyFormElementHasFeedbackFor(state) {
|
||||
return Object.keys(this.formElements).some(name => {
|
||||
if (Array.isArray(this.formElements[name])) {
|
||||
return this.formElements[name].some(el => !!el.hasFeedbackFor.includes(state));
|
||||
return this.formElements[name].some(el => {
|
||||
return Boolean(el.hasFeedbackFor && el.hasFeedbackFor.includes(state));
|
||||
});
|
||||
}
|
||||
return !!this.formElements[name].hasFeedbackFor.includes(state);
|
||||
return Boolean(
|
||||
this.formElements[name].hasFeedbackFor &&
|
||||
this.formElements[name].hasFeedbackFor.includes(state),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -290,6 +290,10 @@ export class OverlayController {
|
|||
}
|
||||
}
|
||||
|
||||
if (!this._renderTarget) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.__isContentNodeProjected && this.placementMode === 'local') {
|
||||
// We add the contentNode in its slot, so that it will be projected by contentWrapperNode
|
||||
this._renderTarget.appendChild(this.contentNode);
|
||||
|
|
@ -635,7 +639,7 @@ export class OverlayController {
|
|||
this.__hasActiveBackdrop = false;
|
||||
break;
|
||||
case 'teardown':
|
||||
if (!this.backdropNode) {
|
||||
if (!this.backdropNode || !this.backdropNode.parentNode) {
|
||||
return;
|
||||
}
|
||||
this.backdropNode.parentNode.removeChild(this.backdropNode);
|
||||
|
|
@ -685,7 +689,7 @@ export class OverlayController {
|
|||
this.__hasActiveBackdrop = false;
|
||||
break;
|
||||
case 'teardown':
|
||||
if (!backdropNode) {
|
||||
if (!backdropNode || !backdropNode.parentNode) {
|
||||
return;
|
||||
}
|
||||
if (animation && this.__backDropAnimation) {
|
||||
|
|
|
|||
|
|
@ -158,6 +158,10 @@ export const OverlayMixin = dedupeMixin(
|
|||
super.disconnectedCallback();
|
||||
}
|
||||
|
||||
if (!this._overlayCtrl) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._overlayDisconnectComplete = new Promise((resolve, reject) => {
|
||||
this.__resolveOverlayDisconnectComplete = resolve;
|
||||
this.__rejectOverlayDisconnectComplete = reject;
|
||||
|
|
@ -168,16 +172,14 @@ export const OverlayMixin = dedupeMixin(
|
|||
this.__resolveOverlayDisconnectComplete();
|
||||
});
|
||||
|
||||
if (this._overlayCtrl) {
|
||||
// We need to prevent that we create a setup/teardown cycle during startup, where it
|
||||
// is common that the overlay system moves around nodes. Therefore, we make the
|
||||
// teardown async, so that it only happens when we are permanently disconnecting from dom
|
||||
this._overlayDisconnectComplete
|
||||
.then(() => {
|
||||
this._teardownOverlayCtrl();
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
// We need to prevent that we create a setup/teardown cycle during startup, where it
|
||||
// is common that the overlay system moves around nodes. Therefore, we make the
|
||||
// teardown async, so that it only happens when we are permanently disconnecting from dom
|
||||
this._overlayDisconnectComplete
|
||||
.then(() => {
|
||||
this._teardownOverlayCtrl();
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
|
||||
get _overlayInvokerNode() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue