Skip to content

Commit 0ab4555

Browse files
authored
Merge pull request #14 from taskbase/fix-click-outside
fix click outside
2 parents 262ba96 + ab209d7 commit 0ab4555

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

projects/angular-keyboard/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@taskbase/angular-keyboard",
3-
"version": "0.0.7",
3+
"version": "0.0.8",
44
"peerDependencies": {
55
"@angular/common": "^8.1.3",
66
"@angular/core": "^8.1.3"

projects/angular-keyboard/src/lib/keyboard-container/keyboard-container.component.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,16 @@ export class KeyboardContainerComponent implements OnInit, OnDestroy {
3333

3434
onClickOnPage(e) {
3535
const isFakeInput = this.angularKeyboardService.inputFields
36-
.map(fakeInputElt => isAncestor(e.target, fakeInputElt.nativeElement))
36+
.map(fakeInputElt => {
37+
try {
38+
// Check if the fake input element is an ancestor of the clicked element
39+
return isAncestor(e.target, fakeInputElt.nativeElement);
40+
} catch {
41+
// It is possible that the clicked element is already not present anymore in the DOM, then isAncestor throws an error.
42+
// In this case assume a click outside to close the keyboard
43+
return false;
44+
}
45+
})
3746
.reduce((a, b) => a || b, false);
3847
if (isFakeInput) {
3948
// don't blur

0 commit comments

Comments
 (0)