Skip to content

Commit a42ac18

Browse files
committed
add ability to change portal container
1 parent 582b88e commit a42ac18

File tree

4 files changed

+200
-224
lines changed

4 files changed

+200
-224
lines changed

.size-snapshot.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
{
22
"dist/index.js": {
3-
"bundled": 6334,
4-
"minified": 6334,
5-
"gzipped": 1993
3+
"bundled": 6414,
4+
"minified": 6414,
5+
"gzipped": 2026
66
},
77
"lib/cjs/index.js": {
8-
"bundled": 12177,
9-
"minified": 6590,
10-
"gzipped": 1926
8+
"bundled": 12375,
9+
"minified": 6670,
10+
"gzipped": 1957
1111
},
1212
"lib/esm/index.js": {
13-
"bundled": 12135,
14-
"minified": 6572,
15-
"gzipped": 1928,
13+
"bundled": 12333,
14+
"minified": 6652,
15+
"gzipped": 1957,
1616
"treeshaked": {
1717
"rollup": {
18-
"code": 6082,
18+
"code": 6162,
1919
"import_statements": 361
2020
},
2121
"webpack": {
22-
"code": 7385
22+
"code": 7467
2323
}
2424
}
2525
}

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@
3838
"author": "Mohsin Ul Haq <[email protected]>",
3939
"license": "MIT",
4040
"browserslist": [
41-
"defaults"
41+
">0.2%",
42+
"not dead",
43+
"not ie <= 11",
44+
"not op_mini all"
4245
],
4346
"prettier": {
4447
"singleQuote": true
@@ -115,7 +118,7 @@
115118
"babel-eslint": "^10.0.1",
116119
"docz": "^0.12.5",
117120
"docz-plugin-css": "^0.11.0",
118-
"eslint": "^5.6.1",
121+
"eslint": "^5.7.0",
119122
"eslint-config-prettier": "^3.1.0",
120123
"eslint-plugin-jsx-a11y": "^6.1.2",
121124
"eslint-plugin-prettier": "^3.0.0",

src/TooltipTrigger.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ export default class TooltipTrigger extends PureComponent {
6969
* whether to use React.createPortal for creating tooltip
7070
*/
7171
usePortal: T.bool,
72+
/**
73+
* element to be used as portal container
74+
*/
75+
portalContainer: T.instanceOf(HTMLElement),
7276
/**
7377
* modifiers passed directly to the underlying popper.js instance
7478
* For more information, refer to Popper.js’ modifier docs:
@@ -85,7 +89,8 @@ export default class TooltipTrigger extends PureComponent {
8589
trigger: 'hover',
8690
closeOnOutOfBoundaries: true,
8791
onVisibilityChange: noop,
88-
usePortal: true
92+
usePortal: true,
93+
portalContainer: document.body
8994
};
9095

9196
state = {
@@ -172,7 +177,8 @@ export default class TooltipTrigger extends PureComponent {
172177
trigger,
173178
modifiers,
174179
closeOnOutOfBoundaries,
175-
usePortal
180+
usePortal,
181+
portalContainer
176182
} = this.props;
177183

178184
const popper = (
@@ -226,7 +232,7 @@ export default class TooltipTrigger extends PureComponent {
226232
}
227233
</Reference>
228234
{this._getState() &&
229-
(usePortal ? createPortal(popper, document.body) : popper)}
235+
(usePortal ? createPortal(popper, portalContainer) : popper)}
230236
</Manager>
231237
);
232238
}

0 commit comments

Comments
 (0)