Skip to content

Commit

Permalink
feat(DropDownGroup): add containerOverride prop (#786)
Browse files Browse the repository at this point in the history
* added containerOverride prop to DropDownGroup

* containerOverride default prop to null

Co-authored-by: Dave Berthiaume <[email protected]>
  • Loading branch information
davebertz and Dave Berthiaume authored Apr 11, 2022
1 parent 6f8a19f commit 07b4e56
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/components/Input/DropDown/DropDownGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 = () => {
Expand Down Expand Up @@ -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 = {
Expand All @@ -419,7 +422,8 @@ DropDownGroup.defaultProps = {
onDropDownToggle: null,
hybrid: false,
dropdownMenuOpen: null,
dropdownMenuClose: null
dropdownMenuClose: null,
containerOverride: null
};

export default DropDownGroup;

0 comments on commit 07b4e56

Please sign in to comment.