Skip to content
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
2 changes: 1 addition & 1 deletion src/demo-app/tooltip/tooltip-demo.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
overflow: auto;

button {
margin: 16px;
margin: 75px 16px 16px;
}
}
.mat-radio-button {
Expand Down
28 changes: 12 additions & 16 deletions src/lib/tooltip/tooltip.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
MatTooltipModule,
SCROLL_THROTTLE_MS,
TOOLTIP_PANEL_CLASS,
TooltipPosition,
MAT_TOOLTIP_DEFAULT_OPTIONS,
} from './index';

Expand Down Expand Up @@ -306,24 +305,21 @@ describe('MatTooltip', () => {
expect(tooltipDirective._isTooltipVisible()).toBe(true);
}));

it('should remove the tooltip when changing position', () => {
const initialPosition: TooltipPosition = 'below';
const changedPosition: TooltipPosition = 'above';

assertTooltipInstance(tooltipDirective, false);

tooltipDirective.position = initialPosition;
it('should be able to update the tooltip position while open', fakeAsync(() => {
tooltipDirective.position = 'below';
tooltipDirective.show();
expect(tooltipDirective._tooltipInstance).toBeTruthy();
tick();

// Same position value should not remove the tooltip
tooltipDirective.position = initialPosition;
expect(tooltipDirective._tooltipInstance).toBeTruthy();
assertTooltipInstance(tooltipDirective, true);

// Different position value should destroy the tooltip
tooltipDirective.position = changedPosition;
assertTooltipInstance(tooltipDirective, false);
});
tooltipDirective.position = 'above';
spyOn(tooltipDirective._overlayRef!, 'updatePosition').and.callThrough();
fixture.detectChanges();
tick();

assertTooltipInstance(tooltipDirective, true);
expect(tooltipDirective._overlayRef!.updatePosition).toHaveBeenCalled();
}));

it('should be able to modify the tooltip message', fakeAsync(() => {
assertTooltipInstance(tooltipDirective, false);
Expand Down
5 changes: 2 additions & 3 deletions src/lib/tooltip/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,9 @@ export class MatTooltip implements OnDestroy {
this._position = value;

if (this._overlayRef) {
// TODO(andrewjs): When the overlay's position can be
// dynamically changed, do not destroy the tooltip.
this._detach();
this._updatePosition();
this._tooltipInstance!.show(value, 0);
this._overlayRef.updatePosition();
}
}
}
Expand Down