Skip to content

Commit

Permalink
fix(atoms): fix ignore outside click class in the Dropdown atom
Browse files Browse the repository at this point in the history
  • Loading branch information
ej9x committed Jun 4, 2018
1 parent a2be371 commit 2ca065b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/atoms/Dropdown/DropdownBody.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow
import fp from 'lodash/fp';
import React, { PureComponent, Fragment } from 'react';
import { type HOC, compose, setDisplayName } from 'recompose';
import { type HOC, compose, setDisplayName, withProps } from 'recompose';
import onClickOutside from 'react-onclickoutside';
import { Popper } from 'react-popper';
import { Portal } from 'react-portal';
Expand Down Expand Up @@ -53,8 +53,11 @@ const setOffset = (offset?: PropSizes) => offset && offset !== 'none'
: fp.identity;

const dropdownBodyEnhancer: HOC<*, DropdownBodyProps> = compose(
setDisplayName('DropdownBody'),
setDisplayName('Dropdown.Body'),
withDropdownContext,
withProps(
({ dropdown: { outsideClickIgnoreClass }}) => ({ outsideClickIgnoreClass }),
),
onClickOutside,
);

Expand All @@ -75,9 +78,9 @@ class DropdownBodyBase extends PureComponent<DropdownBodyEnhancedProps> {
}

handleClickOutside = () => {
const { closeOnClickOutside, onCloseDropdown } = this.props;
const { closeOnClickOutside, dropdown: { closeDropdown }} = this.props;

closeOnClickOutside && onCloseDropdown && onCloseDropdown();
closeOnClickOutside && closeDropdown && closeDropdown();
}

getPopperPlacement = () => {
Expand Down
3 changes: 2 additions & 1 deletion src/atoms/Dropdown/DropdownHead.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import React, { PureComponent } from 'react';
import { Target } from 'react-popper';
import { compose } from 'recompose';
import { compose, setDisplayName } from 'recompose';

import { withDropdownContext } from './DropdownContext';
import { DropdownHeadTag, DropdownPopperTarget } from './DropdownHead.theme';
Expand All @@ -26,6 +26,7 @@ type DropdownHeadProps = {|
|}

const dropdownHeadEnhancer: HOC<*, DropdownHeadProps> = compose(
setDisplayName('Dropdown.Head'),
withDropdownContext,
);

Expand Down
3 changes: 2 additions & 1 deletion src/atoms/Dropdown/DropdownPlate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import React, { Component } from 'react';
import fp from 'lodash/fp';
import { compose, withStateHandlers, branch } from 'recompose';
import { compose, withStateHandlers, branch, setDisplayName } from 'recompose';
import { Manager } from 'react-popper';

import { DropdownContext } from './DropdownContext';
Expand Down Expand Up @@ -91,6 +91,7 @@ class DropdownPlateBase extends Component<DropdownControlledProps> {

/** if component has defaultOpen prop when will add the hoc with isOpen state */
const dropDownEnhancer: { (any): React$ComponentType<DropdownControlledProps | DropdownUncontroledProps> } = compose(
setDisplayName('Dropdown.Plate'),
branch(
(props) => !fp.isNil(props.defaultOpen),
withStateHandlers(
Expand Down

0 comments on commit 2ca065b

Please sign in to comment.