Skip to content

Commit 7774ae1

Browse files
crisbetojelbourn
authored andcommitted
fix(popover-edit): direction not being passed to overlay (#15951)
Fixes the direction of the trigger not being passed to the overlay which can cause it to be out of sync.
1 parent c185950 commit 7774ae1

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

src/cdk-experimental/popover-edit/popover-edit.spec.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {CommonModule} from '@angular/common';
66
import {Component, ElementRef, Type, ViewChild} from '@angular/core';
77
import {ComponentFixture, fakeAsync, flush, TestBed, tick} from '@angular/core/testing';
88
import {FormsModule, NgForm} from '@angular/forms';
9+
import {BidiModule, Direction} from '@angular/cdk/bidi';
910
import {BehaviorSubject} from 'rxjs';
1011

1112
import {CdkPopoverEditColspan, CdkPopoverEditModule, PopoverEditClickOutBehavior} from './index';
@@ -61,6 +62,7 @@ abstract class BaseTestComponent {
6162
ignoreSubmitUnlessValid = true;
6263
clickOutBehavior: PopoverEditClickOutBehavior = 'close';
6364
colspan: CdkPopoverEditColspan = {};
65+
direction: Direction = 'ltr';
6466

6567
onSubmit(element: PeriodicElement, form: NgForm) {
6668
if (!form.valid) { return; }
@@ -147,7 +149,7 @@ abstract class BaseTestComponent {
147149

148150
@Component({
149151
template: `
150-
<table #table editable>
152+
<table #table editable [dir]="direction">
151153
<ng-template #nameEdit let-element>
152154
${NAME_EDIT_TEMPLATE}
153155
</ng-template>
@@ -177,7 +179,7 @@ class VanillaTableOutOfCell extends BaseTestComponent {
177179

178180
@Component({
179181
template: `
180-
<table #table editable>
182+
<table #table editable [dir]="direction">
181183
<tr *ngFor="let element of elements">
182184
<td> just a cell </td>
183185
@@ -218,7 +220,7 @@ class ElementDataSource extends DataSource<PeriodicElement> {
218220

219221
@Component({
220222
template: `
221-
<div #table>
223+
<div #table [dir]="direction">
222224
<cdk-table cdk-table editable [dataSource]="dataSource">
223225
<ng-container cdkColumnDef="before">
224226
<cdk-cell *cdkCellDef="let element">
@@ -264,7 +266,7 @@ class CdkFlexTableInCell extends BaseTestComponent {
264266

265267
@Component({
266268
template: `
267-
<div #table>
269+
<div #table [dir]="direction">
268270
<table cdk-table editable [dataSource]="dataSource">
269271
<ng-container cdkColumnDef="before">
270272
<td cdk-cell *cdkCellDef="let element">
@@ -323,7 +325,7 @@ describe('CDK Popover Edit', () => {
323325

324326
beforeEach(() => {
325327
TestBed.configureTestingModule({
326-
imports: [CdkTableModule, CdkPopoverEditModule, CommonModule, FormsModule],
328+
imports: [CdkTableModule, CdkPopoverEditModule, CommonModule, FormsModule, BidiModule],
327329
declarations: [componentClass],
328330
}).compileComponents();
329331
fixture = TestBed.createComponent(componentClass);
@@ -720,6 +722,16 @@ cdkPopoverEditTabOut`, fakeAsync(() => {
720722

721723
expect(document.activeElement).toBe(component.getEditCell(1));
722724
}));
725+
726+
it('should pass the directionality to the overlay', fakeAsync(() => {
727+
component.direction = 'rtl';
728+
fixture.detectChanges();
729+
730+
component.openLens();
731+
732+
expect(component.getEditBoundingBox()!.getAttribute('dir')).toBe('rtl');
733+
}));
734+
723735
});
724736
});
725737
}

src/cdk-experimental/popover-edit/table-directives.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
NgZone,
1717
OnDestroy,
1818
TemplateRef,
19-
ViewContainerRef
19+
ViewContainerRef,
2020
} from '@angular/core';
2121
import {fromEvent, merge, ReplaySubject} from 'rxjs';
2222
import {debounceTime, filter, map, mapTo, startWith, takeUntil} from 'rxjs/operators';
@@ -221,6 +221,7 @@ export class CdkPopoverEdit<C> implements AfterViewInit, OnDestroy {
221221
panelClass: this.panelClass(),
222222
positionStrategy: this._getPositionStrategy(),
223223
scrollStrategy: this.services.overlay.scrollStrategies.reposition(),
224+
direction: this.services.directionality,
224225
});
225226

226227
this.initFocusTrap();

0 commit comments

Comments
 (0)