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) {
|
_anyFormElementHasFeedbackFor(state) {
|
||||||
return Object.keys(this.formElements).some(name => {
|
return Object.keys(this.formElements).some(name => {
|
||||||
if (Array.isArray(this.formElements[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') {
|
if (this.__isContentNodeProjected && this.placementMode === 'local') {
|
||||||
// We add the contentNode in its slot, so that it will be projected by contentWrapperNode
|
// We add the contentNode in its slot, so that it will be projected by contentWrapperNode
|
||||||
this._renderTarget.appendChild(this.contentNode);
|
this._renderTarget.appendChild(this.contentNode);
|
||||||
|
|
@ -635,7 +639,7 @@ export class OverlayController {
|
||||||
this.__hasActiveBackdrop = false;
|
this.__hasActiveBackdrop = false;
|
||||||
break;
|
break;
|
||||||
case 'teardown':
|
case 'teardown':
|
||||||
if (!this.backdropNode) {
|
if (!this.backdropNode || !this.backdropNode.parentNode) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.backdropNode.parentNode.removeChild(this.backdropNode);
|
this.backdropNode.parentNode.removeChild(this.backdropNode);
|
||||||
|
|
@ -685,7 +689,7 @@ export class OverlayController {
|
||||||
this.__hasActiveBackdrop = false;
|
this.__hasActiveBackdrop = false;
|
||||||
break;
|
break;
|
||||||
case 'teardown':
|
case 'teardown':
|
||||||
if (!backdropNode) {
|
if (!backdropNode || !backdropNode.parentNode) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (animation && this.__backDropAnimation) {
|
if (animation && this.__backDropAnimation) {
|
||||||
|
|
|
||||||
|
|
@ -158,6 +158,10 @@ export const OverlayMixin = dedupeMixin(
|
||||||
super.disconnectedCallback();
|
super.disconnectedCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this._overlayCtrl) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this._overlayDisconnectComplete = new Promise((resolve, reject) => {
|
this._overlayDisconnectComplete = new Promise((resolve, reject) => {
|
||||||
this.__resolveOverlayDisconnectComplete = resolve;
|
this.__resolveOverlayDisconnectComplete = resolve;
|
||||||
this.__rejectOverlayDisconnectComplete = reject;
|
this.__rejectOverlayDisconnectComplete = reject;
|
||||||
|
|
@ -168,16 +172,14 @@ export const OverlayMixin = dedupeMixin(
|
||||||
this.__resolveOverlayDisconnectComplete();
|
this.__resolveOverlayDisconnectComplete();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this._overlayCtrl) {
|
// We need to prevent that we create a setup/teardown cycle during startup, where it
|
||||||
// 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
|
||||||
// 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
|
||||||
// teardown async, so that it only happens when we are permanently disconnecting from dom
|
this._overlayDisconnectComplete
|
||||||
this._overlayDisconnectComplete
|
.then(() => {
|
||||||
.then(() => {
|
this._teardownOverlayCtrl();
|
||||||
this._teardownOverlayCtrl();
|
})
|
||||||
})
|
.catch(() => {});
|
||||||
.catch(() => {});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get _overlayInvokerNode() {
|
get _overlayInvokerNode() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue