Skip to content

Commit 45a6c7d

Browse files
authored
Merge branch 'master' into bkulov/radio-group
2 parents 2b0574f + fcbd993 commit 45a6c7d

File tree

5 files changed

+159
-20
lines changed

5 files changed

+159
-20
lines changed
Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,95 @@
1-
import { Component, ViewChild } from '@angular/core';
1+
import { Component, ViewChild, ViewChildren, QueryList } from '@angular/core';
22
import {
33
async,
44
TestBed
55
} from '@angular/core/testing';
66
import { FormsModule } from '@angular/forms';
77
import { By } from '@angular/platform-browser';
8+
import { IgxIconModule } from '../icon/index';
9+
import { IgxChipsModule } from './chips.module';
10+
import { IgxChipComponent } from './chip.component';
811
import { IgxChipsAreaComponent } from './chips-area.component';
912

13+
@Component({
14+
template: `
15+
<igx-chips-area #chipsArea>
16+
<igx-chip #chipElem *ngFor="let chip of chipList"
17+
[id]="chip.id" [draggable]="chip.draggable" [removable]="chip.removable" [selectable]="chip.selectable">
18+
<igx-icon igxPrefix fontSet="material" [name]="'drag_indicator'"></igx-icon>
19+
<span #label [class]="'igx-chip__text'">{{chip.text}}</span>
20+
<igx-icon class="igx-chip__dir-icon" igxConnector fontSet="material" [name]="'forward'"></igx-icon>
21+
</igx-chip>
22+
</igx-chips-area>
23+
`
24+
})
25+
export class TestChipComponent {
26+
27+
public chipList = [
28+
{ id: 'Country', text: 'Country', removable: false, selectable: false, draggable: true },
29+
{ id: 'City', text: 'City', removable: true, selectable: true, draggable: true }
30+
];
31+
32+
@ViewChild('chipsArea', { read: IgxChipsAreaComponent})
33+
public chipsArea: IgxChipsAreaComponent;
34+
35+
@ViewChildren('chipElem', { read: IgxChipComponent})
36+
public chips: QueryList<IgxChipComponent>;
37+
}
38+
1039
describe('IgxChipsArea', () => {
40+
const CHIP_ITEM_AREA = 'igx-chip__item chip-area';
41+
const CHIP_CONNECTOR = 'igx-chip__connecto';
42+
1143
beforeEach(async(() => {
1244
TestBed.configureTestingModule({
1345
declarations: [
46+
TestChipComponent
1447
],
15-
imports: []
48+
imports: [FormsModule, IgxIconModule, IgxChipsModule]
1649
}).compileComponents();
1750
}));
51+
52+
it('should add chips when adding data items ', () => {
53+
const fix = TestBed.createComponent(TestChipComponent);
54+
fix.detectChanges();
55+
56+
const chipArea = fix.debugElement.queryAll(By.directive(IgxChipsAreaComponent));
57+
const chipAreaComponent = fix.componentInstance;
58+
expect(chipArea[0].nativeElement.children.length).toEqual(2);
59+
60+
chipAreaComponent.chipList.push({ id: 'Town', text: 'Town', removable: true, selectable: true, draggable: true });
61+
62+
fix.detectChanges();
63+
64+
expect(chipArea[0].nativeElement.children.length).toEqual(3);
65+
});
66+
67+
it('should remove chips when removing data items ', () => {
68+
const fix = TestBed.createComponent(TestChipComponent);
69+
fix.detectChanges();
70+
71+
const chipArea = fix.debugElement.queryAll(By.directive(IgxChipsAreaComponent));
72+
const chipAreaComponent = fix.componentInstance;
73+
expect(chipArea[0].nativeElement.children.length).toEqual(2);
74+
75+
chipAreaComponent.chipList.pop();
76+
fix.detectChanges();
77+
78+
expect(chipArea[0].nativeElement.children.length).toEqual(1);
79+
});
80+
81+
it('should change data in chips when data item is changed', () => {
82+
const fix = TestBed.createComponent(TestChipComponent);
83+
fix.detectChanges();
84+
85+
const chipArea = fix.debugElement.queryAll(By.directive(IgxChipsAreaComponent));
86+
const chipAreaComponent = fix.componentInstance;
87+
88+
expect(chipArea[0].nativeElement.children[0].innerHTML).toContain('Country');
89+
90+
chipAreaComponent.chipList[0].text = 'New text';
91+
fix.detectChanges();
92+
93+
expect(chipArea[0].nativeElement.children[0].innerHTML).toContain('New text');
94+
});
1895
});

projects/igniteui-angular/src/lib/core/styles/components/grid/_grid-theme.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,10 @@
391391
box-shadow: $grid-shadow;
392392
outline-style: none;
393393
overflow: hidden;
394+
395+
%cbx-display {
396+
min-width: rem(20px);
397+
}
394398
}
395399

396400
%grid-caption {

projects/igniteui-angular/src/lib/grid/groupby-row.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<ng-container #defaultGroupRow (focus)="onFocus()" (blur)="onBlur()">
22
<div (click)="toggle()" igxRipple class="igx-grid__grouping-indicator" [tabIndex]="tabindex">
3-
<igx-icon *ngIf="!expanded" fontSet="material" name="expand_less"></igx-icon>
3+
<igx-icon *ngIf="!expanded" fontSet="material" name="chevron_right"></igx-icon>
44
<igx-icon *ngIf="expanded" fontSet="material" name="expand_more"></igx-icon>
55
</div>
66

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

Lines changed: 73 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -645,23 +645,21 @@ describe('igxOverlay', () => {
645645
}
646646
}));
647647

648-
it('The shown component is in the center of igx-overlay (visible window) - default.', () => {
648+
it('The shown component is in the center of igx-overlay (visible window) - default.', fakeAsync(() => {
649649
const fixture = TestBed.createComponent(EmptyPageComponent);
650650
fixture.detectChanges();
651651
fixture.componentInstance.overlay.show(SimpleDynamicComponent);
652-
fixture.whenStable().then(() => {
653-
fixture.detectChanges();
654-
const overlayDiv = document.getElementsByClassName(CLASS_OVERLAY_MAIN)[0];
655-
const overlayWrapper = overlayDiv.children[0] as HTMLElement;
656-
const componentEl = overlayWrapper.children[0].children[0];
657-
const wrapperRect = overlayWrapper.getBoundingClientRect();
658-
const componentRect = componentEl.getBoundingClientRect();
659-
expect(wrapperRect.width / 2).toEqual(componentRect.left);
660-
expect(wrapperRect.height / 2).toEqual(componentRect.top);
661-
expect(componentRect.left).toEqual(componentRect.right - componentRect.width);
662-
expect(componentRect.top).toEqual(componentRect.bottom - componentRect.height);
663-
});
664-
});
652+
tick();
653+
const overlayDiv = document.getElementsByClassName(CLASS_OVERLAY_MAIN)[0];
654+
const overlayWrapper = overlayDiv.children[0] as HTMLElement;
655+
const componentEl = overlayWrapper.children[0].children[0];
656+
const wrapperRect = overlayWrapper.getBoundingClientRect();
657+
const componentRect = componentEl.getBoundingClientRect();
658+
expect(wrapperRect.width / 2 - componentRect.width / 2).toEqual(componentRect.left);
659+
expect(wrapperRect.height / 2 - componentRect.height / 2).toEqual(componentRect.top);
660+
expect(componentRect.left).toEqual(componentRect.right - componentRect.width);
661+
expect(componentRect.top).toEqual(componentRect.bottom - componentRect.height);
662+
}));
665663

666664
it('When adding a new instance of a component with the same options, it is rendered exactly on top of the previous one.', () => {
667665
const fixture = TestBed.createComponent(EmptyPageComponent);
@@ -697,8 +695,10 @@ describe('igxOverlay', () => {
697695
const componentEl = overlayWrapper.children[0].children[0];
698696
const wrapperRect = overlayWrapper.getBoundingClientRect();
699697
const componentRect = componentEl.getBoundingClientRect();
700-
expect(wrapperRect.width / 2).toEqual(componentRect.left);
701-
expect(wrapperRect.height / 2).toEqual(componentRect.top);
698+
expect(componentRect.left).toBeLessThan(0);
699+
expect(wrapperRect.width / 2).toEqual(componentRect.left + componentRect.width / 2);
700+
expect(componentRect.top).toBeLessThan(0);
701+
expect(wrapperRect.height / 2).toEqual(componentRect.top + componentRect.height / 2);
702702
hasScrollbar = document.body.scrollHeight > document.body.clientHeight;
703703
expect(hasScrollbar).toBeTruthy();
704704
});
@@ -1746,6 +1746,26 @@ describe('igxOverlay', () => {
17461746
xit('Css should not leak: From shown components to igx-overlay.', () => {
17471747
// TO DO
17481748
});
1749+
1750+
it('Components with 100% width/height should use their initial container\'s properties when placed inside of the overlay element',
1751+
fakeAsync(() => {
1752+
const fixture = TestBed.createComponent(WidthTestOverlayComponent);
1753+
fixture.detectChanges();
1754+
expect(fixture.componentInstance.customComponent).toBeDefined();
1755+
expect(fixture.componentInstance.customComponent.nativeElement.style.width).toEqual('100%');
1756+
expect(fixture.componentInstance.customComponent.nativeElement.getBoundingClientRect().width).toEqual(420);
1757+
expect(fixture.componentInstance.customComponent.nativeElement.style.height).toEqual('100%');
1758+
expect(fixture.componentInstance.customComponent.nativeElement.getBoundingClientRect().height).toEqual(280);
1759+
fixture.componentInstance.buttonElement.nativeElement.click();
1760+
tick();
1761+
const overlayContent = document.getElementsByClassName(CLASS_OVERLAY_CONTENT)[0] as HTMLElement;
1762+
const overlayChild = overlayContent.lastElementChild as HTMLElement;
1763+
expect(overlayChild).toBeDefined();
1764+
expect(overlayChild.style.width).toEqual('100%');
1765+
expect(overlayChild.getBoundingClientRect().width).toEqual(420);
1766+
expect(overlayChild.style.height).toEqual('100%');
1767+
expect(overlayChild.getBoundingClientRect().height).toEqual(280);
1768+
}));
17491769
});
17501770
});
17511771

@@ -1867,13 +1887,49 @@ export class TopLeftOffsetComponent {
18671887
}
18681888
}
18691889

1890+
@Component({
1891+
template: `<div style="width: 420px; height: 280px;">
1892+
<button class='300_button' igxToggle #button (click)=\'click($event)\'>Show Overlay</button>
1893+
<div #myCustomComponent class="customList" style="width: 100%; height: 100%;">
1894+
Some Content
1895+
</div>
1896+
<div>`,
1897+
styles: [`button {
1898+
position: absolute;
1899+
top: 300px;
1900+
left: 300px;
1901+
width: 100px;
1902+
height: 60px;
1903+
border: 0px;
1904+
}`]
1905+
})
1906+
export class WidthTestOverlayComponent {
1907+
1908+
constructor(@Inject(IgxOverlayService) public overlay: IgxOverlayService) { }
1909+
1910+
@ViewChild('button') buttonElement: ElementRef;
1911+
@ViewChild('myCustomComponent') customComponent: ElementRef;
1912+
click(event) {
1913+
const overlaySettings: OverlaySettings = {
1914+
positionStrategy: new ConnectedPositioningStrategy(),
1915+
scrollStrategy: new NoOpScrollStrategy(),
1916+
closeOnOutsideClick: true,
1917+
modal: false
1918+
};
1919+
1920+
overlaySettings.positionStrategy.settings.target = this.buttonElement.nativeElement;
1921+
this.overlay.show(this.customComponent, overlaySettings);
1922+
}
1923+
}
1924+
18701925
const DYNAMIC_COMPONENTS = [
18711926
EmptyPageComponent,
18721927
SimpleRefComponent,
18731928
SimpleDynamicComponent,
18741929
SimpleBigSizeComponent,
18751930
DownRightButtonComponent,
1876-
TopLeftOffsetComponent
1931+
TopLeftOffsetComponent,
1932+
WidthTestOverlayComponent
18771933
];
18781934

18791935
const DIRECTIVE_COMPONENTS = [

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ export class IgxOverlayService {
8787
}
8888

8989
this._overlays.find(c => c.id === id).initialSize = size as DOMRect;
90+
contentElement.style.width = size.width + 'px';
91+
contentElement.style.height = size.height + 'px';
9092
overlaySettings.positionStrategy.position(contentElement, size, document, true);
9193
const animationBuilder = this.builder.build(overlaySettings.positionStrategy.settings.openAnimation);
9294
const animationPlayer = animationBuilder.create(element);

0 commit comments

Comments
 (0)