- {
- children
- ? (
-
- {children}
-
- )
- : null
-
- }
+
+ {mutationRef => {children}
}
+
@@ -507,10 +500,7 @@ EuiPopover.propTypes = {
panelPaddingSize: PropTypes.oneOf(SIZES),
popoverRef: PropTypes.func,
hasArrow: PropTypes.bool,
- container: PropTypes.oneOfType([
- PropTypes.node,
- PropTypes.instanceOf(HTMLElement)
- ]),
+ container: PropTypes.instanceOf(HTMLElement),
/** When `true`, the popover's position is re-calculated when the user scrolls, this supports having fixed-position popover anchors. */
repositionOnScroll: PropTypes.bool,
/** By default, popover content inherits the z-index of the anchor component; pass zIndex to override */
diff --git a/src/components/popover/wrapping_popover.js b/src/components/popover/wrapping_popover.js
index ef94772e8c2..4e6811476c0 100644
--- a/src/components/popover/wrapping_popover.js
+++ b/src/components/popover/wrapping_popover.js
@@ -1,5 +1,4 @@
import React, { Component } from 'react';
-import { findDOMNode } from 'react-dom';
import PropTypes from 'prop-types';
import { EuiPopover } from './popover';
import { EuiPortal } from '../portal';
@@ -14,14 +13,11 @@ export class EuiWrappingPopover extends Component {
super(...args);
this.portal = null;
- this.contentParent = this.props.button.parentNode;
+ this.anchor = null;
}
componentDidMount() {
- const thisDomNode = findDOMNode(this);
- const placeholderAnchor = thisDomNode.querySelector('.euiWrappingPopover__anchor');
-
- placeholderAnchor.insertAdjacentElement(
+ this.anchor.insertAdjacentElement(
'beforebegin',
this.props.button
);
@@ -40,6 +36,10 @@ export class EuiWrappingPopover extends Component {
this.portal = node;
};
+ setAnchorRef = node => {
+ this.anchor = node;
+ }
+
render() {
const {
button, // eslint-disable-line no-unused-vars
@@ -52,7 +52,7 @@ export class EuiWrappingPopover extends Component {
>
}
+ button={
}
/>
);
diff --git a/src/components/portal/portal.js b/src/components/portal/portal.js
index c7f3f8acc38..f20025447f3 100644
--- a/src/components/portal/portal.js
+++ b/src/components/portal/portal.js
@@ -5,7 +5,7 @@
import { Component } from 'react';
import PropTypes from 'prop-types';
-import { createPortal, findDOMNode } from 'react-dom';
+import { createPortal } from 'react-dom';
export const insertPositions = {
'after': 'afterend',
@@ -30,7 +30,7 @@ export class EuiPortal extends Component {
document.body.appendChild(this.portalNode);
} else {
// inserting before or after an element
- findDOMNode(insert.sibling).insertAdjacentElement(
+ insert.sibling.insertAdjacentElement(
insertPositions[insert.position],
this.portalNode
);
@@ -63,13 +63,10 @@ export class EuiPortal extends Component {
EuiPortal.propTypes = {
children: PropTypes.node,
- /** `{sibling: ReactNode|HTMLElement, position: 'before'|'after'}` */
+ /** `{sibling: HTMLElement, position: 'before'|'after'}` */
insert: PropTypes.shape({
- sibling: PropTypes.oneOfType([
- PropTypes.node,
- PropTypes.instanceOf(HTMLElement)
- ]).isRequired,
- position: PropTypes.oneOf(INSERT_POSITIONS),
+ sibling: PropTypes.instanceOf(HTMLElement).isRequired,
+ position: PropTypes.oneOf(INSERT_POSITIONS).isRequired,
}),
portalRef: PropTypes.func,
};
diff --git a/src/components/tool_tip/tool_tip.js b/src/components/tool_tip/tool_tip.js
index 79fadd97dbe..4718464dcd6 100644
--- a/src/components/tool_tip/tool_tip.js
+++ b/src/components/tool_tip/tool_tip.js
@@ -205,7 +205,7 @@ export class EuiToolTip extends Component {
observerOptions={{ subtree: true, childList: true, characterData: true, attributes: true }}
onMutation={this.positionToolTip}
>
- {content}
+ {mutationRef =>
{content}
}
diff --git a/src/services/popover/popover_positioning.js b/src/services/popover/popover_positioning.js
index d19b17169f0..0764db0cd2f 100644
--- a/src/services/popover/popover_positioning.js
+++ b/src/services/popover/popover_positioning.js
@@ -1,5 +1,3 @@
-import { findDOMNode } from 'react-dom';
-
const relatedDimension = {
top: 'height',
right: 'width',
@@ -31,15 +29,15 @@ const positionSubstitutes = {
/**
* Calculates the absolute positioning (relative to document.body) to place a popover element
*
- * @param anchor {HTMLElement|React.Component} Element to anchor the popover to
- * @param popover {HTMLElement|React.Component} Element containing the popover content
+ * @param anchor {HTMLElement} Element to anchor the popover to
+ * @param popover {HTMLElement} Element containing the popover content
* @param position {string} Position the user wants. One of ["top", "right", "bottom", "left"]
* @param [forcePosition] {boolean} If true, use only the provided `position` value and don't try any other position
* @param [align] {string} Cross-axis alignment. One of ["top", "right", "bottom", "left"]
* @param [buffer=16] {number} Minimum distance between the popover and the bounding container
* @param [offset=0] {number} Distance between the popover and the anchor
* @param [allowCrossAxis=true] {boolean} Whether to allow the popover to be positioned on the cross-axis
- * @param [container] {HTMLElement|React.Component} Element the popover must be constrained to fit within
+ * @param [container] {HTMLElement} Element the popover must be constrained to fit within
* @param [arrowConfig] {{arrowWidth: number, arrowBuffer: number}} If present, describes the size & constraints for an arrow element, and the function return value will include an `arrow` param with position details
*
* @returns {{top: number, left: number, position: string, fit: number, arrow?: {left: number, top: number}}|null} absolute page coordinates for the popover,
@@ -57,8 +55,6 @@ export function findPopoverPosition({
container,
arrowConfig
}) {
- container = findDOMNode(container); // resolve any React abstractions
-
// find the screen-relative bounding boxes of the anchor, popover, and container
const anchorBoundingBox = getElementBoundingBox(anchor);
const popoverBoundingBox = getElementBoundingBox(popover);
@@ -446,12 +442,10 @@ function getPrimaryAxisPosition({
* Finds the client pixel coordinate of each edge for the element's bounding box,
* and the bounding box's width & height
*
- * @param {HTMLElement|React.Component} element
+ * @param {HTMLElement} element
* @returns {{top: number, right: number, bottom: number, left: number, height: number, width: number}}
*/
export function getElementBoundingBox(element) {
- element = findDOMNode(element); // resolve any React abstractions
-
const rect = element.getBoundingClientRect();
return {
top: rect.top,
@@ -527,14 +521,11 @@ export function intersectBoundingBoxes(firstBox, secondBox) {
/**
* Returns the top-most defined z-index in the element's ancestor hierarchy
* relative to the `target` element; if no z-index is defined, returns "0"
- * @param element {HTMLElement|React.Component}
- * @param cousin {HTMLElement|React.Component}
+ * @param element {HTMLElement}
+ * @param cousin {HTMLElement}
* @returns {string}
*/
export function getElementZIndex(element, cousin) {
- element = findDOMNode(element);
- cousin = findDOMNode(cousin);
-
/**
* finding the z-index of `element` is not the full story
* its the CSS stacking context that is important
diff --git a/src/services/popover/popover_positioning.test.js b/src/services/popover/popover_positioning.test.js
index 6ed6c225b81..093021cbd91 100644
--- a/src/services/popover/popover_positioning.test.js
+++ b/src/services/popover/popover_positioning.test.js
@@ -1,5 +1,3 @@
-import React, { Component } from 'react';
-import { mount } from 'enzyme';
import {
findPopoverPosition,
getAvailableSpace,
@@ -36,23 +34,6 @@ describe('popover_positioning', () => {
expect(boundingBox).not.toBe(clientRect);
expect(boundingBox).toEqual(clientRect);
});
-
- it('works for React HTML and Component refs', () => {
- class App extends Component {
- render() {
- const { nested } = this.props;
- return (
-
- );
- }
- }
- const component = mount(
);
- expect(getElementBoundingBox(component.ref('spanRef'))).toEqual(clientRect);
- expect(getElementBoundingBox(component.ref('appRef'))).toEqual(clientRect);
- });
});
describe('getAvailableSpace', () => {