Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tooltip): panel element blocks hover effects #5514

Merged
merged 1 commit into from
Jul 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/lib/tooltip/tooltip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ $mat-tooltip-horizontal-padding: 8px;
$mat-tooltip-max-width: 250px;
$mat-tooltip-margin: 14px;

:host {
pointer-events: none;
.mat-tooltip-panel {
// The overlay reference updates the pointer-events style property directly on the HTMLElement
// depending on the state of the overlay. For tooltips the overlay panel should never enable
// pointer events. To overwrite the inline CSS from the overlay reference `!important` is needed.
pointer-events: none !important;
}

.mat-tooltip {
Expand Down
21 changes: 19 additions & 2 deletions src/lib/tooltip/tooltip.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,21 @@ import {
ViewChild,
ChangeDetectionStrategy
} from '@angular/core';
import {
TooltipPosition,
MdTooltip,
MdTooltipModule,
SCROLL_THROTTLE_MS,
TOOLTIP_PANEL_CLASS
} from './index';
import {AnimationEvent} from '@angular/animations';
import {By} from '@angular/platform-browser';
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
import {TooltipPosition, MdTooltip, MdTooltipModule, SCROLL_THROTTLE_MS} from './index';
import {Directionality, Direction} from '../core/bidi/index';
import {OverlayModule, Scrollable, OverlayContainer} from '../core/overlay/index';
import {Platform} from '../core/platform/platform';
import {dispatchFakeEvent} from '@angular/cdk/testing';


const initialTooltipMessage = 'initial tooltip message';

describe('MdTooltip', () => {
Expand Down Expand Up @@ -115,6 +120,18 @@ describe('MdTooltip', () => {
expect(overlayContainerElement.textContent).toContain(initialTooltipMessage);
}));

it('should set a css class on the overlay panel element', fakeAsync(() => {
tooltipDirective.show();
fixture.detectChanges();
tick(0);

const overlayRef = tooltipDirective._overlayRef;

expect(overlayRef).not.toBeNull();
expect(overlayRef!.overlayElement.classList).toContain(TOOLTIP_PANEL_CLASS,
'Expected the overlay panel element to have the tooltip panel class set.');
}));

it('should not show if disabled', fakeAsync(() => {
// Test that disabling the tooltip will not set the tooltip visible
tooltipDirective.disabled = true;
Expand Down
4 changes: 4 additions & 0 deletions src/lib/tooltip/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ export const TOUCHEND_HIDE_DELAY = 1500;
/** Time in ms to throttle repositioning after scroll events. */
export const SCROLL_THROTTLE_MS = 20;

/** CSS class that will be attached to the overlay panel. */
export const TOOLTIP_PANEL_CLASS = 'mat-tooltip-panel';

/** Creates an error to be thrown if the user supplied an invalid tooltip position. */
export function getMdTooltipInvalidPositionError(position: string) {
return Error(`Tooltip position "${position}" is invalid.`);
Expand Down Expand Up @@ -274,6 +277,7 @@ export class MdTooltip implements OnDestroy {

config.direction = this._dir ? this._dir.value : 'ltr';
config.positionStrategy = strategy;
config.panelClass = TOOLTIP_PANEL_CLASS;
config.scrollStrategy = this._overlay.scrollStrategies.reposition({
scrollThrottle: SCROLL_THROTTLE_MS
});
Expand Down