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 3 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

**Bug Fixes**

- Fixed bug in `EuiAccordion` to adjust to the correct height when content height changes ([#3160](https://github.com/elastic/eui/pull/3160))
- Fixed bug in `EuiSuperDatePicker` to show correct values of commonly used values in relative tab ([#3106](https://github.com/elastic/eui/pull/3106))
- Fixed race condition in `EuiIcon` when switching from dynamically fetched components ([#3118](https://github.com/elastic/eui/pull/3118))

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"test-staged"
],
"dependencies": {
"@elastic/eui": "^21.1.0",
winnllam marked this conversation as resolved.
Show resolved Hide resolved
"@types/chroma-js": "^2.0.0",
"@types/enzyme": "^3.1.13",
"@types/lodash": "^4.14.116",
Expand Down Expand Up @@ -152,7 +153,7 @@
"jquery": "^3.2.1",
"markdown-it": "8.4.1",
"mocha": "^5.0.4",
"moment": "^2.20.1",
"moment": "^2.24.0",
winnllam marked this conversation as resolved.
Show resolved Hide resolved
"moment-timezone": "^0.5.27",
"node-sass": "^4.9.3",
"nodegit": "^0.23.0",
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 @@ -42,24 +42,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 @@ -107,24 +98,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 @@ -201,23 +185,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
37 changes: 31 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,36 @@
resolved "https://registry.yarnpkg.com/@elastic/eslint-config-kibana/-/eslint-config-kibana-0.15.0.tgz#a552793497cdfc1829c2f9b7cd7018eb008f1606"
integrity sha1-pVJ5NJfN/Bgpwvm3zXAY6wCPFgY=

"@elastic/eui@^21.1.0":
version "21.1.0"
resolved "https://registry.yarnpkg.com/@elastic/eui/-/eui-21.1.0.tgz#f9a9edc6f682c1a17f8394827c12d7dc57bac7bf"
integrity sha512-U6y/OjM3qfgSZusTVrtpGbYhKXh9bRLqy89JAVo/qrAzzchKCIur9P+AasVF1UG/bUDQEkkmgpNGutbe/BWrJg==
dependencies:
"@types/chroma-js" "^2.0.0"
"@types/enzyme" "^3.1.13"
"@types/lodash" "^4.14.116"
"@types/numeral" "^0.0.25"
"@types/react-beautiful-dnd" "^10.1.0"
"@types/react-input-autosize" "^2.0.2"
"@types/react-virtualized" "^9.18.7"
chroma-js "^2.0.4"
classnames "^2.2.5"
highlight.js "^9.12.0"
html "^1.0.0"
keymirror "^0.1.1"
lodash "^4.17.11"
numeral "^2.0.6"
prop-types "^15.6.0"
react-ace "^7.0.5"
react-beautiful-dnd "^10.1.0"
react-focus-lock "^1.17.7"
react-input-autosize "^2.2.2"
react-is "~16.3.0"
react-virtualized "^9.21.2"
resize-observer-polyfill "^1.5.0"
tabbable "^3.0.0"
uuid "^3.1.0"

"@sentry/core@4.2.4":
version "4.2.4"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-4.2.4.tgz#e4a331512a4db149f14a2976b75a5b3c8ef47f87"
Expand Down Expand Up @@ -9703,16 +9733,11 @@ moment@2.x.x:
resolved "https://registry.yarnpkg.com/moment/-/moment-2.21.0.tgz#2a114b51d2a6ec9e6d83cf803f838a878d8a023a"
integrity sha512-TCZ36BjURTeFTM/CwRcViQlfkMvL1/vFISuNLO5GkcVm1+QHfbSiNqZuWeMFjj1/3+uAjXswgRk30j1kkLYJBQ==

"moment@>= 2.9.0":
"moment@>= 2.9.0", moment@^2.24.0:
version "2.24.0"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.24.0.tgz#0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b"
integrity sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==

moment@^2.20.1:
version "2.20.1"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.20.1.tgz#d6eb1a46cbcc14a2b2f9434112c1ff8907f313fd"
integrity sha512-Yh9y73JRljxW5QxN08Fner68eFLxM5ynNOAw2LbIB1YAGeQzZT8QFSUvkAz609Zf+IHhhaUxqZK8dG3W/+HEvg==

monocle-ts@^1.0.0:
version "1.7.2"
resolved "https://registry.yarnpkg.com/monocle-ts/-/monocle-ts-1.7.2.tgz#d9825ae18846ab63f915cb6f2194a78a40025610"
Expand Down