diff --git a/projects/angular-keyboard/package.json b/projects/angular-keyboard/package.json index acf8c86..4f9274d 100644 --- a/projects/angular-keyboard/package.json +++ b/projects/angular-keyboard/package.json @@ -1,6 +1,6 @@ { "name": "@taskbase/angular-keyboard", - "version": "0.0.7", + "version": "0.0.8", "peerDependencies": { "@angular/common": "^8.1.3", "@angular/core": "^8.1.3" diff --git a/projects/angular-keyboard/src/lib/keyboard-container/keyboard-container.component.ts b/projects/angular-keyboard/src/lib/keyboard-container/keyboard-container.component.ts index b8d1a0d..bab3664 100644 --- a/projects/angular-keyboard/src/lib/keyboard-container/keyboard-container.component.ts +++ b/projects/angular-keyboard/src/lib/keyboard-container/keyboard-container.component.ts @@ -33,7 +33,16 @@ export class KeyboardContainerComponent implements OnInit, OnDestroy { onClickOnPage(e) { const isFakeInput = this.angularKeyboardService.inputFields - .map(fakeInputElt => isAncestor(e.target, fakeInputElt.nativeElement)) + .map(fakeInputElt => { + try { + // Check if the fake input element is an ancestor of the clicked element + return isAncestor(e.target, fakeInputElt.nativeElement); + } catch { + // It is possible that the clicked element is already not present anymore in the DOM, then isAncestor throws an error. + // In this case assume a click outside to close the keyboard + return false; + } + }) .reduce((a, b) => a || b, false); if (isFakeInput) { // don't blur