Skip to content

Commit b3f47b4

Browse files
authored
Merge branch 'master' into dkamburov/expose-totalItemCount
2 parents 16a2660 + a6a8e06 commit b3f47b4

File tree

7 files changed

+85
-17
lines changed

7 files changed

+85
-17
lines changed

projects/igniteui-angular/src/lib/directives/template-outlet/template_outlet.directive.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ export class IgxTemplateOutletDirective implements OnChanges {
107107
this._viewContainerRef.insert(view, 0);
108108
this._updateExistingContext(this.igxTemplateOutletContext);
109109
this.onViewMoved.emit({ owner: this, view: this._viewRef, context: this.igxTemplateOutletContext });
110+
} else {
111+
this._updateExistingContext(this.igxTemplateOutletContext);
110112
}
111113
}
112114
private _useCachedView() {

projects/igniteui-angular/src/lib/grids/cell.component.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,16 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {
620620
if (this.editable && editMode && !this.row.deleted) {
621621
if (editableCell) {
622622
this.gridAPI.update_cell(editableCell, editableCell.editValue);
623+
/* This check is related with the following issue #6517:
624+
* when edit cell that belongs to a column which is sorted and press tab,
625+
* the next cell in edit mode is with wrong value /its context is not updated/;
626+
* So we reapply sorting before the next cell enters edit mode.
627+
* Also we need to keep the notifyChanges below, because of the current
628+
* change detection cycle when we have editing with enabled transactions
629+
*/
630+
if (this.grid.sortingExpressions.length && this.grid.sortingExpressions.indexOf(editableCell.column.field)) {
631+
this.grid.cdr.detectChanges();
632+
}
623633
}
624634
crud.end();
625635
this.grid.notifyChanges();

projects/igniteui-angular/src/lib/services/overlay/overlay.spec.ts

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ describe('igxOverlay', () => {
549549
expect(overlayContentTransform).toEqual(secondTransform);
550550
}));
551551

552-
it('fix for #1690 - click on second filter does not close first one.', fakeAsync(() => {
552+
it('#1690 - click on second filter does not close first one.', fakeAsync(() => {
553553
const fixture = TestBed.createComponent(TwoButtonsComponent);
554554
const button1 = fixture.nativeElement.getElementsByClassName('buttonOne')[0];
555555
const button2 = fixture.nativeElement.getElementsByClassName('buttonTwo')[0];
@@ -566,7 +566,7 @@ describe('igxOverlay', () => {
566566
expect(overlayDiv.children.length).toBe(1);
567567
}));
568568

569-
it('fix for #1692 - scroll strategy closes overlay when shown component is scrolled.', fakeAsync(() => {
569+
it('#1692 - scroll strategy closes overlay when shown component is scrolled.', fakeAsync(() => {
570570
const fixture = TestBed.createComponent(SimpleDynamicWithDirectiveComponent);
571571
const overlaySettings: OverlaySettings = { scrollStrategy: new CloseScrollStrategy() };
572572
fixture.componentInstance.show(overlaySettings);
@@ -593,7 +593,7 @@ describe('igxOverlay', () => {
593593
}));
594594

595595
// TODO: refactor utilities to include all exported methods in a class
596-
it('fix for #1799 - content div should reposition on window resize.', fakeAsync(() => {
596+
it('#1799 - content div should reposition on window resize.', fakeAsync(() => {
597597
const rect: ClientRect = {
598598
bottom: 50,
599599
height: 0,
@@ -635,7 +635,7 @@ describe('igxOverlay', () => {
635635
overlayInstance.hide(id);
636636
}));
637637

638-
it('fix for #2475 - An error is thrown for IgxOverlay when showing a component' +
638+
it('#2475 - An error is thrown for IgxOverlay when showing a component' +
639639
'instance that is not attached to the DOM', fakeAsync(() => {
640640
const fix = TestBed.createComponent(SimpleRefComponent);
641641
fix.detectChanges();
@@ -656,7 +656,7 @@ describe('igxOverlay', () => {
656656
expect(contentDiv.classList.contains(CLASS_OVERLAY_CONTENT_MODAL)).toBeTruthy();
657657
}));
658658

659-
it('fix for #2486 - filtering dropdown is not correctly positioned', fakeAsync(() => {
659+
it('#2486 - filtering dropdown is not correctly positioned', fakeAsync(() => {
660660
const fix = TestBed.createComponent(WidthTestOverlayComponent);
661661
fix.debugElement.nativeElement.style.transform = 'translatex(100px)';
662662

@@ -676,7 +676,7 @@ describe('igxOverlay', () => {
676676
expect(fix.componentInstance.customComponent.nativeElement.getBoundingClientRect().left).toBe(400);
677677
}));
678678

679-
it('fix for #2798 - Allow canceling of open and close of IgxDropDown through onOpening and onClosing events', fakeAsync(() => {
679+
it('#2798 - Allow canceling of open and close of IgxDropDown through onOpening and onClosing events', fakeAsync(() => {
680680
const fix = TestBed.createComponent(SimpleRefComponent);
681681
fix.detectChanges();
682682
const overlayInstance = fix.componentInstance.overlay;
@@ -713,7 +713,7 @@ describe('igxOverlay', () => {
713713
expect(overlayInstance.onOpened.emit).toHaveBeenCalledTimes(1);
714714
}));
715715

716-
it('fix for #3673 - Should not close dropdown in dropdown', fakeAsync(() => {
716+
it('#3673 - Should not close dropdown in dropdown', fakeAsync(() => {
717717
const fix = TestBed.createComponent(EmptyPageComponent);
718718
const button = fix.componentInstance.buttonElement;
719719
const overlay = fix.componentInstance.overlay;
@@ -749,7 +749,7 @@ describe('igxOverlay', () => {
749749
expect(overlayDiv.children[0].localName).toEqual('div');
750750
}));
751751

752-
it('fix for #3743 - Reposition correctly resized element.', () => {
752+
it('#3743 - Reposition correctly resized element.', () => {
753753
const fixture = TestBed.createComponent(TopLeftOffsetComponent);
754754
fixture.detectChanges();
755755

@@ -801,7 +801,7 @@ describe('igxOverlay', () => {
801801
document.body.removeChild(wrapperElement);
802802
});
803803

804-
it('Fix for #3988 - Should use ngModuleRef to create component', inject([ApplicationRef], (appRef: ApplicationRef) => {
804+
it('#3988 - Should use ngModuleRef to create component', inject([ApplicationRef], (appRef: ApplicationRef) => {
805805
const fixture = TestBed.createComponent(EmptyPageComponent);
806806
const overlay = fixture.componentInstance.overlay;
807807
fixture.detectChanges();
@@ -825,6 +825,46 @@ describe('igxOverlay', () => {
825825
expect(appRef.attachView).toHaveBeenCalledWith('test');
826826
expect(overlay.getOverlayById(id).componentRef as any).toBe(mockComponent);
827827
}));
828+
829+
it('##6474 - should calculate correctly position', () => {
830+
const elastic: ElasticPositionStrategy = new ElasticPositionStrategy();
831+
const targetRect: ClientRect = {
832+
top: 100,
833+
bottom: 200,
834+
height: 100,
835+
left: 100,
836+
right: 200,
837+
width: 100
838+
};
839+
const elementRect: ClientRect = {
840+
top: 0,
841+
bottom: 300,
842+
height: 300,
843+
left: 0,
844+
right: 300,
845+
width: 300
846+
};
847+
const viewPortRect: ClientRect = {
848+
top: 1000,
849+
bottom: 1300,
850+
height: 300,
851+
left: 1000,
852+
right: 1300,
853+
width: 300
854+
};
855+
spyOn<any>(elastic, 'setStyle').and.returnValue({});
856+
spyOn(Util, 'getViewportRect').and.returnValue(viewPortRect);
857+
spyOn(Util, 'getTargetRect').and.returnValue(targetRect);
858+
859+
const element = jasmine.createSpyObj('HTMLElement', ['getBoundingClientRect'] );
860+
spyOn(element, 'getBoundingClientRect').and.returnValue(elementRect);
861+
element.classList = { add: () => {} };
862+
element.style = { width: '', height: ''};
863+
elastic.position(element, null, null, true);
864+
865+
expect(element.style.width).toBe('200px');
866+
expect(element.style.height).toBe('100px');
867+
});
828868
});
829869

830870
describe('Unit Tests - Scroll Strategies: ', () => {
@@ -2617,7 +2657,7 @@ describe('igxOverlay', () => {
26172657
tick();
26182658
}));
26192659

2620-
// Test fix for #1883 #1820
2660+
// Test #1883 #1820
26212661
it('It should close the component when esc key is pressed and there were other keys pressed prior to esc.', fakeAsync(() => {
26222662
const fixture = TestBed.createComponent(EmptyPageComponent);
26232663
const overlay = fixture.componentInstance.overlay;

projects/igniteui-angular/src/lib/services/overlay/position/auto-position-strategy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class AutoPositionStrategy extends BaseFitPositionStrategy {
5050
const leftBorder = this.calculateLeft(
5151
connectedFit.targetRect, connectedFit.contentElementRect, flippedStartPoint, flippedDirection, 0);
5252
const rightBorder = leftBorder + connectedFit.contentElementRect.width;
53-
return connectedFit.viewPortRect.left < leftBorder && rightBorder < connectedFit.viewPortRect.right;
53+
return 0 < leftBorder && rightBorder < connectedFit.viewPortRect.width;
5454
}
5555

5656
/**
@@ -65,7 +65,7 @@ export class AutoPositionStrategy extends BaseFitPositionStrategy {
6565
const topBorder = this.calculateTop(
6666
connectedFit.targetRect, connectedFit.contentElementRect, flippedStartPoint, flippedDirection, 0);
6767
const bottomBorder = topBorder + connectedFit.contentElementRect.height;
68-
return connectedFit.viewPortRect.top < topBorder && bottomBorder < connectedFit.viewPortRect.bottom;
68+
return 0 < topBorder && bottomBorder < connectedFit.viewPortRect.height;
6969
}
7070

7171
/**

projects/igniteui-angular/src/lib/services/overlay/position/base-fit-position-strategy.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ export abstract class BaseFitPositionStrategy extends ConnectedPositioningStrate
3838
connectedFit.horizontalOffset ? connectedFit.horizontalOffset : 0);
3939
connectedFit.right = connectedFit.left + connectedFit.contentElementRect.width;
4040
connectedFit.fitHorizontal = {
41-
back: Math.round(connectedFit.left - connectedFit.viewPortRect.left),
42-
forward: Math.round(connectedFit.viewPortRect.right - connectedFit.right)
41+
back: Math.round(connectedFit.left),
42+
forward: Math.round(connectedFit.viewPortRect.width - connectedFit.right)
4343
};
4444

4545
connectedFit.top = this.calculateTop(
@@ -50,8 +50,8 @@ export abstract class BaseFitPositionStrategy extends ConnectedPositioningStrate
5050
connectedFit.verticalOffset ? connectedFit.verticalOffset : 0);
5151
connectedFit.bottom = connectedFit.top + connectedFit.contentElementRect.height;
5252
connectedFit.fitVertical = {
53-
back: Math.round(connectedFit.top - connectedFit.viewPortRect.top),
54-
forward: Math.round(connectedFit.viewPortRect.bottom - connectedFit.bottom)
53+
back: Math.round(connectedFit.top),
54+
forward: Math.round(connectedFit.viewPortRect.height - connectedFit.bottom)
5555
};
5656
}
5757

src/app/hierarchical-grid/hierarchical-grid.sample.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ <h4 class="sample-title">Sample three</h4>
109109
<h4 class="sample-title">Sample 4</h4>
110110
<div class="sample-actions">
111111
<button igxButton="raised" (click)='LoadMoreColumns()'>Change columns runtime</button>
112+
<button igxButton="raised" (click)='changeData()'>Change data runtime</button>
112113
</div>
113-
<igx-hierarchical-grid [data]="localData" [autoGenerate]="false" [height]="'600px'" [width]="'800px'" #hGrid2>
114+
<igx-hierarchical-grid [data]="localData1" [autoGenerate]="false" [height]="'600px'" [width]="'800px'" #hGrid2>
114115
<igx-column field="ID" [resizable]="true" [pinned]="true" [filterable]='true'></igx-column>
115116
<igx-column field="ChildLevels" [resizable]="true" [groupable]='true'></igx-column>
116117
<igx-column field="ProductName" hasSummary='true'></igx-column>

src/app/hierarchical-grid/hierarchical-grid.sample.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import {
1313
})
1414
export class HierarchicalGridSampleComponent {
1515
localData = [];
16+
localData1 = [];
17+
data1 = [];
18+
data2 = [];
1619
isRowSelectable = false;
1720
firstLevelExpanded = false;
1821
rootExpanded = false;
@@ -48,6 +51,9 @@ export class HierarchicalGridSampleComponent {
4851
{ label: 'comfortable', selected: this.density === 'comfortable', togglable: true }
4952
];
5053
this.localData = this.generateDataUneven(100, 3);
54+
this.data1 = this.localData.slice(0, 10);
55+
this.data2 = this.localData.slice(10, 20);
56+
this.localData1 = this.data1;
5157
this.localData[0].hasChild = false;
5258
this.localData[1].hasChild = false;
5359
this.localData[2].childData[0].hasChild = false;
@@ -139,4 +145,13 @@ export class HierarchicalGridSampleComponent {
139145
this.columns = ['Col1', 'Col2', 'Col3'];
140146
this.childColumns = ['ChildCol1', 'ChildCol2'];
141147
}
148+
149+
public changeData() {
150+
debugger;
151+
if (this.localData1 === this.data1) {
152+
this.localData1 = this.data2;
153+
} else {
154+
this.localData1 = this.data1;
155+
}
156+
}
142157
}

0 commit comments

Comments
 (0)