|
6 | 6 | ViewChild, |
7 | 7 | HostBinding, |
8 | 8 | ApplicationRef, |
9 | | - ComponentRef |
| 9 | + ComponentRef, |
| 10 | + ViewEncapsulation |
10 | 11 | } from '@angular/core'; |
11 | 12 | import { TestBed, fakeAsync, tick, async, inject } from '@angular/core/testing'; |
12 | 13 | import { BrowserModule, By } from '@angular/platform-browser'; |
@@ -177,9 +178,9 @@ function formatString(inputString: string, formatters: any[]) { |
177 | 178 |
|
178 | 179 | describe('igxOverlay', () => { |
179 | 180 | const formatters = [ |
180 | | - {pattern: /:\s/g, replacement: ':'}, |
181 | | - {pattern: /red;/, replacement: 'red'} |
182 | | - ]; |
| 181 | + { pattern: /:\s/g, replacement: ':' }, |
| 182 | + { pattern: /red;/, replacement: 'red' } |
| 183 | + ]; |
183 | 184 | beforeEach(async(() => { |
184 | 185 | UIInteractions.clearOverlay(); |
185 | 186 | })); |
@@ -825,7 +826,7 @@ describe('igxOverlay', () => { |
825 | 826 | fix.detectChanges(); |
826 | 827 |
|
827 | 828 | const overlaySettings: OverlaySettings = { |
828 | | - target : button.nativeElement, |
| 829 | + target: button.nativeElement, |
829 | 830 | positionStrategy: new ConnectedPositioningStrategy(), |
830 | 831 | modal: false, |
831 | 832 | closeOnOutsideClick: true |
@@ -997,6 +998,46 @@ describe('igxOverlay', () => { |
997 | 998 | overlayDiv = document.getElementsByClassName(CLASS_OVERLAY_MAIN)[0]; |
998 | 999 | expect(overlayDiv).toBeUndefined(); |
999 | 1000 | })); |
| 1001 | + |
| 1002 | + it('should correctly handle close on outside click in shadow DOM', fakeAsync(() => { |
| 1003 | + const fix = TestBed.createComponent(EmptyPageInShadowDomComponent); |
| 1004 | + const button = fix.componentInstance.buttonElement; |
| 1005 | + const outlet = fix.componentInstance.outletElement; |
| 1006 | + const overlay = fix.componentInstance.overlay; |
| 1007 | + fix.detectChanges(); |
| 1008 | + |
| 1009 | + const overlaySettings: OverlaySettings = { |
| 1010 | + modal: false, |
| 1011 | + closeOnOutsideClick: true, |
| 1012 | + positionStrategy: new ConnectedPositioningStrategy(), |
| 1013 | + target: button.nativeElement, |
| 1014 | + outlet: outlet |
| 1015 | + }; |
| 1016 | + |
| 1017 | + overlay.show(overlay.attach(SimpleDynamicComponent), overlaySettings); |
| 1018 | + tick(); |
| 1019 | + fix.detectChanges(); |
| 1020 | + |
| 1021 | + let overlayDiv: Element = outlet.nativeElement.getElementsByTagName('component')[0]; |
| 1022 | + expect(overlayDiv).toBeDefined(); |
| 1023 | + |
| 1024 | + const toggledDiv = overlayDiv.children[0]; |
| 1025 | + (toggledDiv as any).click(); |
| 1026 | + |
| 1027 | + tick(); |
| 1028 | + fix.detectChanges(); |
| 1029 | + |
| 1030 | + overlayDiv = outlet.nativeElement.getElementsByTagName('component')[0]; |
| 1031 | + expect(overlayDiv).toBeDefined(); |
| 1032 | + |
| 1033 | + document.body.click(); |
| 1034 | + |
| 1035 | + tick(); |
| 1036 | + fix.detectChanges(); |
| 1037 | + |
| 1038 | + overlayDiv = outlet.nativeElement.getElementsByTagName('component')[0]; |
| 1039 | + expect(overlayDiv).toBeUndefined(); |
| 1040 | + })); |
1000 | 1041 | }); |
1001 | 1042 |
|
1002 | 1043 | describe('Unit Tests - Scroll Strategies: ', () => { |
@@ -1453,20 +1494,20 @@ describe('igxOverlay', () => { |
1453 | 1494 |
|
1454 | 1495 | it(`Should use StartPoint:Left/Bottom, Direction Right/Bottom and openAnimation: scaleInVerTop, |
1455 | 1496 | closeAnimation: scaleOutVerTop as default options when using a ConnectedPositioningStrategy without passing options.`, () => { |
1456 | | - const strategy = new ConnectedPositioningStrategy(); |
| 1497 | + const strategy = new ConnectedPositioningStrategy(); |
1457 | 1498 |
|
1458 | | - const expectedDefaults = { |
1459 | | - horizontalDirection: HorizontalAlignment.Right, |
1460 | | - verticalDirection: VerticalAlignment.Bottom, |
1461 | | - horizontalStartPoint: HorizontalAlignment.Left, |
1462 | | - verticalStartPoint: VerticalAlignment.Bottom, |
1463 | | - openAnimation: scaleInVerTop, |
1464 | | - closeAnimation: scaleOutVerTop, |
1465 | | - minSize: { width: 0, height: 0 } |
1466 | | - }; |
| 1499 | + const expectedDefaults = { |
| 1500 | + horizontalDirection: HorizontalAlignment.Right, |
| 1501 | + verticalDirection: VerticalAlignment.Bottom, |
| 1502 | + horizontalStartPoint: HorizontalAlignment.Left, |
| 1503 | + verticalStartPoint: VerticalAlignment.Bottom, |
| 1504 | + openAnimation: scaleInVerTop, |
| 1505 | + closeAnimation: scaleOutVerTop, |
| 1506 | + minSize: { width: 0, height: 0 } |
| 1507 | + }; |
1467 | 1508 |
|
1468 | | - expect(strategy.settings).toEqual(expectedDefaults); |
1469 | | - }); |
| 1509 | + expect(strategy.settings).toEqual(expectedDefaults); |
| 1510 | + }); |
1470 | 1511 |
|
1471 | 1512 | // adding more than one component to show in igx-overlay: |
1472 | 1513 | it('Should render the component exactly on top of the previous one when adding a new instance with default settings.', () => { |
@@ -3925,6 +3966,20 @@ export class EmptyPageComponent { |
3925 | 3966 | } |
3926 | 3967 | } |
3927 | 3968 |
|
| 3969 | +@Component({ |
| 3970 | + template: ` |
| 3971 | + <button #button>Show Overlay</button> |
| 3972 | + <div igxOverlayOutlet #outlet></div> |
| 3973 | + `, |
| 3974 | + encapsulation: ViewEncapsulation.ShadowDom |
| 3975 | +}) |
| 3976 | +export class EmptyPageInShadowDomComponent { |
| 3977 | + constructor(@Inject(IgxOverlayService) public overlay: IgxOverlayService) { } |
| 3978 | + |
| 3979 | + @ViewChild('button', { static: true }) buttonElement: ElementRef; |
| 3980 | + @ViewChild('outlet', { static: true }) outletElement: ElementRef; |
| 3981 | +} |
| 3982 | + |
3928 | 3983 | @Component({ |
3929 | 3984 | template: `<button #button (click)='click($event)'>Show Overlay</button>`, |
3930 | 3985 | styles: [`button { |
@@ -4012,7 +4067,6 @@ export class TwoButtonsComponent { |
4012 | 4067 | ev.stopPropagation(); |
4013 | 4068 | } |
4014 | 4069 | } |
4015 | | - |
4016 | 4070 | @Component({ |
4017 | 4071 | template: ` |
4018 | 4072 | <div style="width: 420px; height: 280px;"> |
@@ -4112,6 +4166,7 @@ export class FlexContainerComponent { |
4112 | 4166 | const DYNAMIC_COMPONENTS = [ |
4113 | 4167 | EmptyPageComponent, |
4114 | 4168 | SimpleRefComponent, |
| 4169 | + EmptyPageInShadowDomComponent, |
4115 | 4170 | SimpleDynamicComponent, |
4116 | 4171 | SimpleBigSizeComponent, |
4117 | 4172 | DownRightButtonComponent, |
|
0 commit comments