Skip to content

Commit

Permalink
fix(core) Remove shadow dom example | Add composedPath method check (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
salarenko committed Sep 30, 2020
1 parent bae50da commit 5cd5ba7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, TemplateRef } from '@angular/core';
import { DialogConfig, DialogService } from '@fundamental-ngx/core';
import { DialogService } from '@fundamental-ngx/core';

@Component({
selector: 'fd-popover-dialog-example',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component } from '@angular/core';
import { RtlService } from '@fundamental-ngx/core';
import { BehaviorSubject, Observable } from 'rxjs';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

const bottomStart = 'bottom-start';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { map } from 'rxjs/operators';
selector: 'fd-popover-example',
templateUrl: './popover-example.component.html',
styleUrls: ['popover-example.component.scss'],
encapsulation: ViewEncapsulation.ShadowDom
encapsulation: ViewEncapsulation.None
})
export class PopoverExampleComponent {
leftPlacement$: Observable<Placement>;
Expand All @@ -24,10 +24,4 @@ export class PopoverExampleComponent {
{ text: 'Option 2', url: '#' },
{ text: 'Option 3', url: '#' }
];

list2 = [
{ text: 'Option 3', url: '#' },
{ text: 'Option 4', url: '#' },
{ text: 'Option 5', url: '#' }
];
}
10 changes: 8 additions & 2 deletions libs/core/src/lib/popover/popover-directive/popover.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,13 +416,19 @@ export class PopoverDirective implements OnInit, OnDestroy, OnChanges {
/** @hidden */
private _containerContainsTarget(event: Event): boolean {
const containerElement = this.containerRef.location.nativeElement;
return containerElement.contains(event.composedPath()[0]);
return containerElement.contains(this._getEventTarget(event));
}

/** @hidden */
private _triggerContainsTarget(event: Event): boolean {
const triggerElement = this.triggerRef.nativeElement;
return triggerElement.contains(event.composedPath()[0]);
return triggerElement.contains(this._getEventTarget(event));
}

private _getEventTarget(event: Event): EventTarget {
return event.composedPath
? event.composedPath()[0]
: event.target;
}

/** @hidden */
Expand Down

0 comments on commit 5cd5ba7

Please sign in to comment.