Skip to content

Commit

Permalink
Merge pull request #14 from chandlerprall/feature/1137-global-patterns
Browse files Browse the repository at this point in the history
Fix global filters position on window resize
  • Loading branch information
cchaos authored Sep 6, 2018
2 parents ae6eed6 + fa3f802 commit b1083ff
Showing 1 changed file with 21 additions and 24 deletions.
45 changes: 21 additions & 24 deletions src-docs/src/views/header/global_query.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React, { Component } from 'react';
import classNames from 'classnames';

import ResizeObserver from 'resize-observer-polyfill';
import {
EuiFilterButton,
EuiFieldText,
EuiFlexGroup,
EuiFlexItem,
EuiMutationObserver,
} from '../../../../src/components';

import { GlobalFilterBar } from './global_filter_bar';
Expand Down Expand Up @@ -58,6 +57,8 @@ export default class extends Component {
],
query: '',
};

this.ro = new ResizeObserver(this.setFilterBarHeight);
}

setFilterBarHeight = () => {
Expand All @@ -69,10 +70,12 @@ export default class extends Component {

componentDidMount() {
this.setFilterBarHeight();
this.ro.observe(this.filterBar);
}

componentDidUpdate() {
this.setFilterBarHeight();
this.ro.unobserve(this.filterBar);
}

toggleFilterVisibility = () => {
Expand Down Expand Up @@ -132,28 +135,22 @@ export default class extends Component {
ref={node => { this.filterBarWrapper = node; }}
className={classes}
>
<EuiMutationObserver
observerOptions={{ childList: true, subtree: true }}
onMutation={this.setFilterBarHeight}
>
<div ref={this.setFilterBarRef}>
<EuiFlexGroup
className="globalFilterGroup"
gutterSize="none"
alignItems="flexStart"
responsive={false}
>
<EuiFlexItem className="globalFilterGroup__branch" grow={false}>
<GlobalFilterOptions />
</EuiFlexItem>

<EuiFlexItem>
<GlobalFilterBar className="globalFilterGroup__filterBar" filters={this.state.filters} />
</EuiFlexItem>
</EuiFlexGroup>
</div>

</EuiMutationObserver>
<div ref={this.setFilterBarRef}>
<EuiFlexGroup
className="globalFilterGroup"
gutterSize="none"
alignItems="flexStart"
responsive={false}
>
<EuiFlexItem className="globalFilterGroup__branch" grow={false}>
<GlobalFilterOptions />
</EuiFlexItem>

<EuiFlexItem>
<GlobalFilterBar className="globalFilterGroup__filterBar" filters={this.state.filters} />
</EuiFlexItem>
</EuiFlexGroup>
</div>
</div>

</React.Fragment>
Expand Down

0 comments on commit b1083ff

Please sign in to comment.