Merge pull request #794 from ing-bank/fix/overlayCatchRejectedPromise

fix(overlays): only teardown when overlayCtrl defined
This commit is contained in:
Thijs Louisse 2020-07-07 10:16:22 +02:00 committed by GitHub
commit 29d740c87d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 14 deletions

View file

@ -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),
);
});
}

View file

@ -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) {

View file

@ -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,7 +172,6 @@ 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
@ -178,7 +181,6 @@ export const OverlayMixin = dedupeMixin(
})
.catch(() => {});
}
}
get _overlayInvokerNode() {
return Array.from(this.children).find(child => child.slot === 'invoker');