Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Date pickups not working on filters #1638

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/BrowserFilter/BrowserFilter.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export default class BrowserFilter extends React.Component {
filters={this.state.filters}
onChange={filters => this.setState({ filters: filters })}
renderRow={props => (
<FilterRow {...props} active={this.props.filters.size > 0} />
<FilterRow {...props} active={this.props.filters.size > 0} parentContentId={POPOVER_CONTENT_ID} />
)}
/>
<div className={styles.footer}>
Expand Down
8 changes: 5 additions & 3 deletions src/components/BrowserFilter/FilterRow.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let setFocus = (input) => {
}
}

function compareValue(info, value, onChangeCompareTo, active) {
function compareValue(info, value, onChangeCompareTo, active, parentContentId) {
switch (info.type) {
case null:
return null;
Expand Down Expand Up @@ -70,7 +70,8 @@ function compareValue(info, value, onChangeCompareTo, active) {
className={styles.date}
value={Parse._decode('date', value)}
onChange={(value) => onChangeCompareTo(Parse._encode(value))}
ref={setFocus} />
ref={setFocus}
parentContentId={parentContentId} />
);
}
}
Expand All @@ -87,6 +88,7 @@ let FilterRow = ({
onChangeCompareTo,
onDeleteRow,
active,
parentContentId,
}) => (
<div className={styles.row}>
<ChromeDropdown
Expand All @@ -100,7 +102,7 @@ let FilterRow = ({
value={Constraints[currentConstraint].name}
options={constraints.map((c) => Constraints[c].name)}
onChange={(c) => onChangeConstraint(constraintLookup[c])} />
{compareValue(compareInfo, compareTo, onChangeCompareTo, active)}
{compareValue(compareInfo, compareTo, onChangeCompareTo, active, parentContentId)}
<a role='button' href='javascript:;' className={styles.remove} onClick={onDeleteRow}><Icon name='minus-solid' width={14} height={14} fill='rgba(0,0,0,0.4)' /></a>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/DateTimeEntry/DateTimeEntry.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default class DateTimeEntry extends React.Component {
let popover = null;
if (this.state.open) {
popover = (
<Popover fixed={true} position={this.state.position} onExternalClick={this.close.bind(this)}>
<Popover fixed={true} position={this.state.position} onExternalClick={this.close.bind(this)} parentContentId={this.props.parentContentId}>
<DateTimePicker
value={this.props.value}
width={Math.max(this.node.clientWidth, 240)}
Expand Down
5 changes: 4 additions & 1 deletion src/components/Popover/Popover.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ export default class Popover extends React.Component {
if (this.props.fadeIn) {
this._popoverLayer.className = styles.transition;
}
if (this.props.parentContentId) {
this._popoverLayer.dataset.parentContentId = this.props.parentContentId;
}

document.body.addEventListener('click', this._checkExternalClick);
}
Expand All @@ -78,7 +81,7 @@ export default class Popover extends React.Component {
: this._popoverLayer;
const isChromeDropdown = e.target.parentNode.classList.contains('chromeDropdown');
if (
!hasAncestor(e.target, popoverWrapper) &&
!hasAncestor(e.target, popoverWrapper, contentId) &&
this.props.onExternalClick &&
!isChromeDropdown
) {
Expand Down
4 changes: 3 additions & 1 deletion src/lib/hasAncestor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
* This source code is licensed under the license found in the LICENSE file in
* the root directory of this source tree.
*/
export default function hasAncestor(node, ancestor) {
export default function hasAncestor(node, ancestor, contentId) {
let cur = node.parentNode;
while (cur && cur.nodeType === 1) {
if (cur === ancestor) {
return true;
} else if (contentId && cur.dataset.parentContentId === contentId) {
return true;
}
cur = cur.parentNode;
}
Expand Down