mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-12-27 10:33:56 +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.
|
||||
onMouseOver: (e) ->
|
||||
target = @_elementWithTooltip(e.target)
|
||||
if target then @_onTooltipEnter(target)
|
||||
if target and @_targetIsVisible(target) then @_onTooltipEnter(target)
|
||||
else if @state.display then @_hideTooltip()
|
||||
|
||||
onMouseOut: (e) ->
|
||||
if @_elementWithTooltip(e.fromElement) and not @_elementWithTooltip(e.toElement)
|
||||
@_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) ->
|
||||
while target
|
||||
break if target?.dataset?.tooltip?
|
||||
|
|
Loading…
Reference in a new issue