Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(tooltip): now works inside elements without pointer events
Browse files Browse the repository at this point in the history
closes #1101, #1232
  • Loading branch information
rschmukler committed Feb 7, 2015
1 parent 74fe870 commit 3d010cd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/components/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ function MdTooltipDirective($timeout, $window, $$rAF, $document, $mdUtil, $mdThe
$mdTheming(element);
var parent = element.parent();

// Keep looking for a higher parent if our current one has no pointer events
while (parent[0].style.pointerEvents == 'none') {
parent = parent.parent();
}

// Look for the nearest parent md-content, stopping at the rootElement.
var current = element.parent()[0];
while (current && current !== $rootElement[0] && current !== document.body) {
Expand Down
8 changes: 8 additions & 0 deletions src/components/tooltip/tooltip.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ describe('<md-tooltip> directive', function() {
expect($rootScope.isVisible).toBe(false);
}));

it('should not set parent to items with no pointer events', inject(function($compile, $rootScope, $timeout) {
var element = $compile('<outer><inner style="pointer-events: none;"><md-tooltip md-visible="isVisible">Hello world' +
'</md-tooltip></inner></outer>')($rootScope);
element.triggerHandler('mouseenter');
$timeout.flush();
expect($rootScope.isVisible).toBe(true);
}));

it('should set visible on focus and blur', inject(function($compile, $rootScope, $timeout) {
var element = $compile('<md-button>' +
'Hello' +
Expand Down

0 comments on commit 3d010cd

Please sign in to comment.