mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-12-28 19:31:14 +08:00
fix(tooltip): don't show tooltips for hidden items
This commit is contained in:
parent
3dbbc6b474
commit
453e449955
1 changed files with 11 additions and 1 deletions
|
@ -47,13 +47,23 @@ Tooltip = React.createClass
|
||||||
# listeners.
|
# listeners.
|
||||||
onMouseOver: (e) ->
|
onMouseOver: (e) ->
|
||||||
target = @_elementWithTooltip(e.target)
|
target = @_elementWithTooltip(e.target)
|
||||||
if target then @_onTooltipEnter(target)
|
if target and @_targetIsVisible(target) then @_onTooltipEnter(target)
|
||||||
else if @state.display then @_hideTooltip()
|
else if @state.display then @_hideTooltip()
|
||||||
|
|
||||||
onMouseOut: (e) ->
|
onMouseOut: (e) ->
|
||||||
if @_elementWithTooltip(e.fromElement) and not @_elementWithTooltip(e.toElement)
|
if @_elementWithTooltip(e.fromElement) and not @_elementWithTooltip(e.toElement)
|
||||||
@_onTooltipLeave()
|
@_onTooltipLeave()
|
||||||
|
|
||||||
|
_targetIsVisible: (target) ->
|
||||||
|
while target
|
||||||
|
style = window.getComputedStyle(target)
|
||||||
|
target = target.parentNode
|
||||||
|
continue unless style?
|
||||||
|
# NOTE: opacity must be soft ==
|
||||||
|
if style.opacity is 0 or style.opacity is "0" or style.visibility is "hidden" or style.display is "none"
|
||||||
|
return false
|
||||||
|
return true
|
||||||
|
|
||||||
_elementWithTooltip: (target) ->
|
_elementWithTooltip: (target) ->
|
||||||
while target
|
while target
|
||||||
break if target?.dataset?.tooltip?
|
break if target?.dataset?.tooltip?
|
||||||
|
|
Loading…
Reference in a new issue