@@ -8,7 +8,7 @@ import * as popperJS from "popper.js";
8
8
export interface PopoverProps {
9
9
referenceElementId : string ;
10
10
placement : string ; // TODO: use a union type of allowed values
11
-
11
+ parentId ?: string ;
12
12
content ?: string ;
13
13
classNames ?: string [ ] ;
14
14
arrowClassNames ?: string [ ] ;
@@ -25,12 +25,21 @@ class PopoverClass extends ComponentBase<{}, PopoverProps> {
25
25
26
26
handlePopoverLifecycle ( element , isInitialized , context ) {
27
27
if ( ! isInitialized ) {
28
- let popperElement = this . generatePopperElement ( Constants . Ids . mainController ) ;
29
- this . refToPopper = new popperJS ( document . getElementById ( this . props . referenceElementId ) , popperElement , {
28
+ let popperElement = this . generatePopperElement ( this . props . parentId ) ;
29
+
30
+ // TODO temporarily typed this way until definitions is updated for popperJS.PopperOptions
31
+ let popperOptions : any = {
30
32
placement : this . props . placement ,
31
- modifiersIgnored : this . props . modifiersIgnored ,
32
- removeOnDestroy : this . props . removeOnDestroy
33
- } ) ;
33
+ removeOnDestroy : this . props . removeOnDestroy ,
34
+ modifiers : { }
35
+ } ;
36
+ if ( this . props . modifiersIgnored ) {
37
+ for ( let i = 0 ; i < this . props . modifiersIgnored . length ; i ++ ) {
38
+ popperOptions . modifiers [ this . props . modifiersIgnored [ i ] ] = { enabled : false } ;
39
+ }
40
+ }
41
+
42
+ this . refToPopper = new popperJS ( document . getElementById ( this . props . referenceElementId ) , popperElement , popperOptions ) ;
34
43
}
35
44
36
45
if ( isInitialized ) {
@@ -65,7 +74,7 @@ class PopoverClass extends ComponentBase<{}, PopoverProps> {
65
74
popperElement . appendChild ( arrowElement ) ;
66
75
}
67
76
68
- let parent = document . getElementById ( parentId ) ;
77
+ let parent = parentId ? document . getElementById ( parentId ) : undefined ;
69
78
if ( parent ) {
70
79
// We want to set the parent lower in the HTML hierarchy to avoid z-index issues relating to stacking contexts
71
80
parent . appendChild ( popperElement ) ;
0 commit comments