fixes bug with keyboard input in click tooltips

Co-Authored-By: David Wilson <daviwil@users.noreply.github.com>
This commit is contained in:
Tilde Ann Thurium
2018-09-12 16:17:30 -07:00
parent c609a3e0c0
commit f7b95d03d3
2 changed files with 10 additions and 2 deletions

View File

@@ -153,11 +153,10 @@ class TooltipManager {
}
window.addEventListener('resize', hideTooltip)
window.addEventListener('keydown', hideTooltip, { capture: true })
const disposable = new Disposable(() => {
window.removeEventListener('resize', hideTooltip)
window.removeEventListener('keydown', hideTooltip, { capture: true })
hideTooltip()
tooltip.destroy()

View File

@@ -82,6 +82,7 @@ Tooltip.prototype.init = function (element, options) {
var eventIn, eventOut
if (trigger === 'hover') {
this.hideOnKeydownOutsideOfTooltip = () => this.hide()
if (this.options.selector) {
eventIn = 'mouseover'
eventOut = 'mouseout'
@@ -220,6 +221,10 @@ Tooltip.prototype.show = function () {
window.addEventListener('click', this.hideOnClickOutsideOfTooltip, true)
}
if (this.hideOnKeydownOutsideOfTooltip) {
window.addEventListener('keydown', this.hideOnKeydownOutsideOfTooltip, true)
}
var tip = this.getTooltipElement()
this.startObservingMutations()
var tipId = this.getUID('tooltip')
@@ -359,6 +364,10 @@ Tooltip.prototype.hide = function (callback) {
window.removeEventListener('click', this.hideOnClickOutsideOfTooltip, true)
}
if (this.hideOnKeydownOutsideOfTooltip) {
window.removeEventListener('keydown', this.hideOnKeydownOutsideOfTooltip, true)
}
this.tip && this.tip.classList.remove('in')
this.stopObservingMutations()