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
22 changes: 22 additions & 0 deletions src/lib/core/overlay/overlay-directives.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import {ConnectedOverlayDirective, OverlayModule} from './overlay-directives';
import {OverlayContainer} from './overlay-container';
import {ConnectedPositionStrategy} from './position/connected-position-strategy';
import {ConnectedOverlayPositionChange} from './position/connected-position';
import {Dir} from '../rtl/dir';


describe('Overlay directives', () => {
let overlayContainerElement: HTMLElement;
let fixture: ComponentFixture<ConnectedOverlayDirectiveTest>;
let dir: {value: string};

beforeEach(() => {
TestBed.configureTestingModule({
Expand All @@ -19,6 +21,9 @@ describe('Overlay directives', () => {
{provide: OverlayContainer, useFactory: () => {
overlayContainerElement = document.createElement('div');
return {getContainerElement: () => overlayContainerElement};
}},
{provide: Dir, useFactory: () => {
return dir = { value: 'ltr' };
}}
],
});
Expand Down Expand Up @@ -76,6 +81,23 @@ describe('Overlay directives', () => {
expect(positions.length).toBeGreaterThan(0);
});

it('should set and update the `dir` attribute', () => {
dir.value = 'rtl';
fixture.componentInstance.isOpen = true;
fixture.detectChanges();

expect(getPaneElement().getAttribute('dir')).toBe('rtl');

fixture.componentInstance.isOpen = false;
fixture.detectChanges();

dir.value = 'ltr';
fixture.componentInstance.isOpen = true;
fixture.detectChanges();

expect(getPaneElement().getAttribute('dir')).toBe('ltr');
});

describe('inputs', () => {

it('should set the width', () => {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/core/overlay/overlay-directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,6 @@ export class ConnectedOverlayDirective implements OnDestroy {
this._position = this._createPositionStrategy() as ConnectedPositionStrategy;
overlayConfig.positionStrategy = this._position;

overlayConfig.direction = this.dir;

return overlayConfig;
}

Expand All @@ -223,7 +221,6 @@ export class ConnectedOverlayDirective implements OnDestroy {

const strategy = this._overlay.position()
.connectedTo(this.origin.elementRef, originPoint, overlayPoint)
.withDirection(this.dir)
.withOffsetX(this.offsetX)
.withOffsetY(this.offsetY);

Expand All @@ -250,6 +247,9 @@ export class ConnectedOverlayDirective implements OnDestroy {
this._createOverlay();
}

this._position.withDirection(this.dir);
this._overlayRef.getState().direction = this.dir;

if (!this._overlayRef.hasAttached()) {
this._overlayRef.attach(this._templatePortal);
this.attach.emit();
Expand Down