Skip to content

Commit d8aeeaa

Browse files
crisbetojelbourn
authored andcommitted
fix(tooltip): not using trigger's text direction (#4413)
Passes the trigger's layout direction along to the tooltip element. Fixes #4411.
1 parent ef6b9aa commit d8aeeaa

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/lib/tooltip/tooltip.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,19 @@ describe('MdTooltip', () => {
353353
tooltipDirective.show();
354354
}).toThrowError('Tooltip position "everywhere" is invalid.');
355355
});
356+
357+
it('should pass the layout direction to the tooltip', fakeAsync(() => {
358+
dir.value = 'rtl';
359+
360+
tooltipDirective.show();
361+
tick(0);
362+
fixture.detectChanges();
363+
364+
const tooltipWrapper = overlayContainerElement.querySelector('.cdk-overlay-pane');
365+
366+
expect(tooltipWrapper).toBeTruthy('Expected tooltip to be shown.');
367+
expect(tooltipWrapper.getAttribute('dir')).toBe('rtl', 'Expected tooltip to be in RTL mode.');
368+
}));
356369
});
357370

358371
describe('scrollable usage', () => {

src/lib/tooltip/tooltip.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ export class MdTooltip implements OnDestroy {
235235
this.hide(0);
236236
}
237237
});
238+
238239
let config = new OverlayState();
240+
config.direction = this._dir ? this._dir.value : 'ltr';
239241
config.positionStrategy = strategy;
240242
config.scrollStrategy =
241243
new RepositionScrollStrategy(this._scrollDispatcher, SCROLL_THROTTLE_MS);

0 commit comments

Comments
 (0)