Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

Commit

Permalink
Disable outsideClick listener from FilterFrequency component #1387
Browse files Browse the repository at this point in the history
if tether DatePicker was shown
  • Loading branch information
wiadev committed Jan 17, 2018
1 parent c21f9ad commit 8178717
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 9 deletions.
19 changes: 17 additions & 2 deletions src/components/filters/FiltersFrequent.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ const classes = "btn btn-filter btn-meta-outline-secondary btn-sm";
class FiltersFrequent extends Component {
state = { openFilterId: null };

constructor(props) {
super(props);
this.state = {
allowOutsideClickListener: true
};
}

toggleFilter = index => {
this.setState({
openFilterId: index
Expand All @@ -24,8 +31,15 @@ class FiltersFrequent extends Component {

outsideClick = () => {
const { widgetShown, dropdownToggled } = this.props;
!widgetShown && this.toggleFilter(null, null);
dropdownToggled();
const { allowOutsideClickListener } = this.state;
if (allowOutsideClickListener) {
!widgetShown && this.toggleFilter(null, null);
dropdownToggled();
}
};

allowOutsideClickListener = value => {
this.setState({ allowOutsideClickListener: value });
};

render() {
Expand Down Expand Up @@ -115,6 +129,7 @@ class FiltersFrequent extends Component {
onHide={() => handleShow(false)}
viewId={viewId}
outsideClick={this.outsideClick}
allowOutsideClickListener={this.allowOutsideClickListener}
/>
)}
</div>
Expand Down
11 changes: 9 additions & 2 deletions src/components/filters/FiltersItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ class FiltersItem extends Component {
onHide,
viewId,
outsideClick,
captionValue
captionValue,
allowOutsideClickListener
} = this.props;

const { filter, isTooltipShow } = this.state;
Expand Down Expand Up @@ -198,7 +199,13 @@ class FiltersItem extends Component {
caption={item.caption}
noLabel={false}
filterWidget={true}
{...{ viewId, windowType, onShow, onHide }}
{...{
viewId,
windowType,
onShow,
onHide,
allowOutsideClickListener
}}
/>
))}
</div>
Expand Down
9 changes: 6 additions & 3 deletions src/components/widget/DatePicker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import PropTypes from "prop-types";
import React, { Component } from "react";
import Datetime from "react-datetime";
import { connect } from "react-redux";
import TetheredDateTime from "./TetheredDateTime";
import { addNotification } from "../../actions/AppActions";
Expand All @@ -11,7 +10,8 @@ const propTypes = {
patch: PropTypes.func,
field: PropTypes.string,
value: PropTypes.any,
isOpenDatePicker: PropTypes.bool
isOpenDatePicker: PropTypes.bool,
allowOutsideClickListener: PropTypes.func // function to manage outside Click Listener from FilterFrequency component
};

class DatePicker extends Component {
Expand Down Expand Up @@ -51,17 +51,20 @@ class DatePicker extends Component {
};

handleFocus = () => {
const { value } = this.props;
const { value, allowOutsideClickListener } = this.props;
this.setState({
cache: value,
open: true
});
allowOutsideClickListener && allowOutsideClickListener(false);
};

handleClose = () => {
const { allowOutsideClickListener } = this.props;
this.setState({
open: false
});
allowOutsideClickListener && allowOutsideClickListener(true);
};

handleClickOutside = () => {
Expand Down
8 changes: 6 additions & 2 deletions src/components/widget/RawWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ class RawWidget extends Component {
attribute,
allowShowPassword,
onBlurWidget,
defaultValue
defaultValue,
allowOutsideClickListener
} = this.props;
const widgetValue = data || widgetData[0].value;
const { isEdited } = this.state;
Expand Down Expand Up @@ -297,7 +298,10 @@ class RawWidget extends Component {
date ? Moment(date).format(DATE_FORMAT) : null
)
}
handleBackdropLock={handleBackdropLock}
{...{
allowOutsideClickListener,
handleBackdropLock
}}
/>
];
}
Expand Down

0 comments on commit 8178717

Please sign in to comment.