|
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 } 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 | })); |
@@ -996,6 +997,46 @@ describe('igxOverlay', () => { |
996 | 997 | overlayDiv = document.getElementsByClassName(CLASS_OVERLAY_MAIN)[0]; |
997 | 998 | expect(overlayDiv).toBeUndefined(); |
998 | 999 | })); |
| 1000 | + |
| 1001 | + it('should correctly handle close on outside click in shadow DOM', fakeAsync(() => { |
| 1002 | + const fix = TestBed.createComponent(EmptyPageInShadowDomComponent); |
| 1003 | + const button = fix.componentInstance.buttonElement; |
| 1004 | + const outlet = fix.componentInstance.outletElement; |
| 1005 | + const overlay = fix.componentInstance.overlay; |
| 1006 | + fix.detectChanges(); |
| 1007 | + |
| 1008 | + const overlaySettings: OverlaySettings = { |
| 1009 | + modal: false, |
| 1010 | + closeOnOutsideClick: true, |
| 1011 | + positionStrategy: new ConnectedPositioningStrategy(), |
| 1012 | + outlet: outlet |
| 1013 | + }; |
| 1014 | + |
| 1015 | + overlaySettings.positionStrategy.settings.target = button.nativeElement; |
| 1016 | + overlay.show(overlay.attach(SimpleDynamicComponent), overlaySettings); |
| 1017 | + tick(); |
| 1018 | + fix.detectChanges(); |
| 1019 | + |
| 1020 | + let overlayDiv: Element = outlet.nativeElement.getElementsByTagName('component')[0]; |
| 1021 | + expect(overlayDiv).toBeDefined(); |
| 1022 | + |
| 1023 | + const toggledDiv = overlayDiv.children[0]; |
| 1024 | + (toggledDiv as any).click(); |
| 1025 | + |
| 1026 | + tick(); |
| 1027 | + fix.detectChanges(); |
| 1028 | + |
| 1029 | + overlayDiv = outlet.nativeElement.getElementsByTagName('component')[0]; |
| 1030 | + expect(overlayDiv).toBeDefined(); |
| 1031 | + |
| 1032 | + document.body.click(); |
| 1033 | + |
| 1034 | + tick(); |
| 1035 | + fix.detectChanges(); |
| 1036 | + |
| 1037 | + overlayDiv = outlet.nativeElement.getElementsByTagName('component')[0]; |
| 1038 | + expect(overlayDiv).toBeUndefined(); |
| 1039 | + })); |
999 | 1040 | }); |
1000 | 1041 |
|
1001 | 1042 | describe('Unit Tests - Scroll Strategies: ', () => { |
@@ -1431,44 +1472,44 @@ describe('igxOverlay', () => { |
1431 | 1472 |
|
1432 | 1473 | it(`Should use StartPoint:Left/Bottom, Direction Right/Bottom and openAnimation: scaleInVerTop, closeAnimation: scaleOutVerTop |
1433 | 1474 | as default options when using a ConnectedPositioningStrategy without passing other but target element options.`, () => { |
1434 | | - const targetEl: HTMLElement = <HTMLElement>document.getElementsByClassName('300_button')[0]; |
1435 | | - const positionSettings2 = { |
1436 | | - target: targetEl |
1437 | | - }; |
| 1475 | + const targetEl: HTMLElement = <HTMLElement>document.getElementsByClassName('300_button')[0]; |
| 1476 | + const positionSettings2 = { |
| 1477 | + target: targetEl |
| 1478 | + }; |
1438 | 1479 |
|
1439 | | - const strategy = new ConnectedPositioningStrategy(positionSettings2); |
| 1480 | + const strategy = new ConnectedPositioningStrategy(positionSettings2); |
1440 | 1481 |
|
1441 | | - const expectedDefaults = { |
1442 | | - target: targetEl, |
1443 | | - horizontalDirection: HorizontalAlignment.Right, |
1444 | | - verticalDirection: VerticalAlignment.Bottom, |
1445 | | - horizontalStartPoint: HorizontalAlignment.Left, |
1446 | | - verticalStartPoint: VerticalAlignment.Bottom, |
1447 | | - openAnimation: scaleInVerTop, |
1448 | | - closeAnimation: scaleOutVerTop, |
1449 | | - minSize: { width: 0, height: 0 } |
1450 | | - }; |
| 1482 | + const expectedDefaults = { |
| 1483 | + target: targetEl, |
| 1484 | + horizontalDirection: HorizontalAlignment.Right, |
| 1485 | + verticalDirection: VerticalAlignment.Bottom, |
| 1486 | + horizontalStartPoint: HorizontalAlignment.Left, |
| 1487 | + verticalStartPoint: VerticalAlignment.Bottom, |
| 1488 | + openAnimation: scaleInVerTop, |
| 1489 | + closeAnimation: scaleOutVerTop, |
| 1490 | + minSize: { width: 0, height: 0 } |
| 1491 | + }; |
1451 | 1492 |
|
1452 | | - expect(strategy.settings).toEqual(expectedDefaults); |
1453 | | - }); |
| 1493 | + expect(strategy.settings).toEqual(expectedDefaults); |
| 1494 | + }); |
1454 | 1495 |
|
1455 | 1496 | it(`Should use target: null StartPoint:Left/Bottom, Direction Right/Bottom and openAnimation: scaleInVerTop, |
1456 | 1497 | closeAnimation: scaleOutVerTop as default options when using a ConnectedPositioningStrategy without passing options.`, () => { |
1457 | | - const strategy = new ConnectedPositioningStrategy(); |
| 1498 | + const strategy = new ConnectedPositioningStrategy(); |
1458 | 1499 |
|
1459 | | - const expectedDefaults = { |
1460 | | - target: null, |
1461 | | - horizontalDirection: HorizontalAlignment.Right, |
1462 | | - verticalDirection: VerticalAlignment.Bottom, |
1463 | | - horizontalStartPoint: HorizontalAlignment.Left, |
1464 | | - verticalStartPoint: VerticalAlignment.Bottom, |
1465 | | - openAnimation: scaleInVerTop, |
1466 | | - closeAnimation: scaleOutVerTop, |
1467 | | - minSize: { width: 0, height: 0 } |
1468 | | - }; |
| 1500 | + const expectedDefaults = { |
| 1501 | + target: null, |
| 1502 | + horizontalDirection: HorizontalAlignment.Right, |
| 1503 | + verticalDirection: VerticalAlignment.Bottom, |
| 1504 | + horizontalStartPoint: HorizontalAlignment.Left, |
| 1505 | + verticalStartPoint: VerticalAlignment.Bottom, |
| 1506 | + openAnimation: scaleInVerTop, |
| 1507 | + closeAnimation: scaleOutVerTop, |
| 1508 | + minSize: { width: 0, height: 0 } |
| 1509 | + }; |
1469 | 1510 |
|
1470 | | - expect(strategy.settings).toEqual(expectedDefaults); |
1471 | | - }); |
| 1511 | + expect(strategy.settings).toEqual(expectedDefaults); |
| 1512 | + }); |
1472 | 1513 |
|
1473 | 1514 | // adding more than one component to show in igx-overlay: |
1474 | 1515 | it('Should render the component exactly on top of the previous one when adding a new instance with default settings.', () => { |
@@ -3801,6 +3842,20 @@ export class EmptyPageComponent { |
3801 | 3842 | } |
3802 | 3843 | } |
3803 | 3844 |
|
| 3845 | +@Component({ |
| 3846 | + template: ` |
| 3847 | + <button #button>Show Overlay</button> |
| 3848 | + <div igxOverlayOutlet #outlet></div> |
| 3849 | + `, |
| 3850 | + encapsulation: ViewEncapsulation.ShadowDom |
| 3851 | +}) |
| 3852 | +export class EmptyPageInShadowDomComponent { |
| 3853 | + constructor(@Inject(IgxOverlayService) public overlay: IgxOverlayService) { } |
| 3854 | + |
| 3855 | + @ViewChild('button', { static: true }) buttonElement: ElementRef; |
| 3856 | + @ViewChild('outlet', { static: true }) outletElement: ElementRef; |
| 3857 | +} |
| 3858 | + |
3804 | 3859 | @Component({ |
3805 | 3860 | template: `<button #button (click)='click($event)'>Show Overlay</button>`, |
3806 | 3861 | styles: [`button { |
@@ -3886,7 +3941,6 @@ export class TwoButtonsComponent { |
3886 | 3941 | ev.stopPropagation(); |
3887 | 3942 | } |
3888 | 3943 | } |
3889 | | - |
3890 | 3944 | @Component({ |
3891 | 3945 | template: ` |
3892 | 3946 | <div style="width: 420px; height: 280px;"> |
@@ -3986,6 +4040,7 @@ export class FlexContainerComponent { |
3986 | 4040 | const DYNAMIC_COMPONENTS = [ |
3987 | 4041 | EmptyPageComponent, |
3988 | 4042 | SimpleRefComponent, |
| 4043 | + EmptyPageInShadowDomComponent, |
3989 | 4044 | SimpleDynamicComponent, |
3990 | 4045 | SimpleBigSizeComponent, |
3991 | 4046 | DownRightButtonComponent, |
|
0 commit comments