Skip to content

Commit

Permalink
Better handling blur events on popovers
Browse files Browse the repository at this point in the history
  • Loading branch information
lqez committed Jun 1, 2020
1 parent abd60c5 commit c53d938
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/js/base/module/ImagePopover.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,18 @@ export default class ImagePopover {
this.options = context.options;

this.events = {
'summernote.disable summernote.blur': () => {
'summernote.disable summernote.dialog.shown': () => {
this.hide();
},
'summernote.blur': (we, e) => {
if (e.originalEvent && e.originalEvent.relatedTarget) {
if (!this.$popover[0].contains(e.originalEvent.relatedTarget)) {
this.hide();
}
} else {
this.hide();
}
},
};
}

Expand Down
11 changes: 10 additions & 1 deletion src/js/base/module/LinkPopover.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,18 @@ export default class LinkPopover {
'summernote.keyup summernote.mouseup summernote.change summernote.scroll': () => {
this.update();
},
'summernote.disable summernote.dialog.shown summernote.blur': () => {
'summernote.disable summernote.dialog.shown': () => {
this.hide();
},
'summernote.blur': (we, e) => {
if (e.originalEvent && e.originalEvent.relatedTarget) {
if (!this.$popover[0].contains(e.originalEvent.relatedTarget)) {
this.hide();
}
} else {
this.hide();
}
},
};
}

Expand Down
11 changes: 10 additions & 1 deletion src/js/base/module/TablePopover.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,18 @@ export default class TablePopover {
'summernote.keyup summernote.scroll summernote.change': () => {
this.update();
},
'summernote.disable summernote.blur': () => {
'summernote.disable summernote.dialog.shown': () => {
this.hide();
},
'summernote.blur': (we, e) => {
if (e.originalEvent && e.originalEvent.relatedTarget) {
if (!this.$popover[0].contains(e.originalEvent.relatedTarget)) {
this.hide();
}
} else {
this.hide();
}
},
};
}

Expand Down

0 comments on commit c53d938

Please sign in to comment.