diff --git a/src/components/Input/DropDown/DropDownGroup.js b/src/components/Input/DropDown/DropDownGroup.js index 8b09b3f6..31525714 100644 --- a/src/components/Input/DropDown/DropDownGroup.js +++ b/src/components/Input/DropDown/DropDownGroup.js @@ -31,7 +31,8 @@ class DropDownGroup extends React.Component { static LAYOUT_VARIANTS = LAYOUT_VARIANTS; componentDidMount() { - document.addEventListener("click", this.handleOutsideClick); + const container = this.props.containerOverride || document; + container.addEventListener("click", this.handleOutsideClick); } static getDerivedStateFromProps(props, state) { @@ -58,7 +59,8 @@ class DropDownGroup extends React.Component { } componentWillUnmount() { - document.removeEventListener("click", this.handleOutsideClick); + const container = this.props.containerOverride || document; + container.removeEventListener("click", this.handleOutsideClick); } onClick = () => { @@ -396,7 +398,8 @@ DropDownGroup.propTypes = { onDropDownToggle: PropTypes.func, hybrid: PropTypes.bool, dropdownMenuOpen: PropTypes.func, - dropdownMenuClose: PropTypes.func + dropdownMenuClose: PropTypes.func, + containerOverride: PropTypes.node }; DropDownGroup.defaultProps = { @@ -419,7 +422,8 @@ DropDownGroup.defaultProps = { onDropDownToggle: null, hybrid: false, dropdownMenuOpen: null, - dropdownMenuClose: null + dropdownMenuClose: null, + containerOverride: null }; export default DropDownGroup;