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

Fixes to EuiAccordion adjust exposed height #3160

Merged
merged 6 commits into from
Mar 31, 2020
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
- Added `title` and `aria` attributes to `EuiToken`'s icon element ([#3195](https://github.com/elastic/eui/pull/3195))
- Added new Elasticsearch token types ([58036](https://github.com/elastic/kibana/issues/58036))

**Bug Fixes**

- Fixed bug in `EuiAccordion` to adjust to the correct height when content height changes ([#3160](https://github.com/elastic/eui/pull/3160))

## [`22.2.0`](https://github.com/elastic/eui/tree/v22.2.0)

- Improved `EuiModal` close button position to prevent from overlapping with the title ([#3176](https://github.com/elastic/eui/pull/3176))
Expand Down
30 changes: 6 additions & 24 deletions src/components/accordion/__snapshots__/accordion.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,15 @@ exports[`EuiAccordion behavior closes when clicked twice 1`] = `
className="euiAccordion__childWrapper"
id="8"
>
<EuiMutationObserver
observerOptions={
Object {
"attributeFilter": Array [
"style",
],
"childList": true,
"subtree": true,
}
}
onMutation={[Function]}
<EuiResizeObserver
onResize={[Function]}
>
<div>
<div
className=""
/>
</div>
</EuiMutationObserver>
</EuiResizeObserver>
</div>
</div>
</EuiAccordion>
Expand Down Expand Up @@ -111,24 +102,15 @@ exports[`EuiAccordion behavior opens when clicked once 1`] = `
className="euiAccordion__childWrapper"
id="7"
>
<EuiMutationObserver
observerOptions={
Object {
"attributeFilter": Array [
"style",
],
"childList": true,
"subtree": true,
}
}
onMutation={[Function]}
<EuiResizeObserver
onResize={[Function]}
>
<div>
<div
className=""
/>
</div>
</EuiMutationObserver>
</EuiResizeObserver>
</div>
</div>
</EuiAccordion>
Expand Down
32 changes: 5 additions & 27 deletions src/components/accordion/accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import classNames from 'classnames';
import { CommonProps, keysOf } from '../common';

import { EuiIcon } from '../icon';
import { EuiMutationObserver } from '../observer/mutation_observer';
import { getDurationAndPerformOnFrame } from '../../services';

const MUTATION_ATTRIBUTE_FILTER = ['style'];
import { EuiResizeObserver } from '../observer/resize_observer';

const paddingSizeToClassNameMap = {
none: '',
Expand Down Expand Up @@ -87,19 +84,6 @@ export class EuiAccordion extends Component<
});
};

onMutation = (records: MutationRecord[]) => {
const isChildStyleMutation = records.find((record: MutationRecord) => {
return record.attributeName
? MUTATION_ATTRIBUTE_FILTER.indexOf(record.attributeName) > -1
: false;
});
if (isChildStyleMutation) {
getDurationAndPerformOnFrame(records, this.setChildContentHeight);
} else {
this.setChildContentHeight();
}
};

componentDidMount() {
this.setChildContentHeight();
}
Expand Down Expand Up @@ -207,23 +191,17 @@ export class EuiAccordion extends Component<
this.childWrapper = node;
}}
id={id}>
<EuiMutationObserver
observerOptions={{
childList: true,
subtree: true,
attributeFilter: MUTATION_ATTRIBUTE_FILTER,
}}
onMutation={this.onMutation}>
{mutationRef => (
<EuiResizeObserver onResize={this.setChildContentHeight}>
{resizeRef => (
<div
ref={ref => {
this.setChildContentRef(ref);
mutationRef(ref);
resizeRef(ref);
}}>
<div className={paddingClass}>{children}</div>
</div>
)}
</EuiMutationObserver>
</EuiResizeObserver>
</div>
</div>
);
Expand Down