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

[EuiAccordion] Fix resize observer loop error when drag&dropping an accordion #6031

Merged
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
28 changes: 17 additions & 11 deletions src/components/accordion/accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ export class EuiAccordionClass extends Component<

generatedId = htmlIdGenerator()();

// Storing resize/observer refs as an instance variable is a performance optimization
// and also resolves https://github.com/elastic/eui/issues/5903
resizeRef: (e: HTMLElement | null) => void = () => {};
observerRef = (ref: HTMLDivElement) => {
this.setChildContentRef(ref);
this.resizeRef(ref);
};

render() {
const {
children,
Expand Down Expand Up @@ -384,18 +392,16 @@ export class EuiAccordionClass extends Component<
id={id}
>
<EuiResizeObserver onResize={this.setChildContentHeight}>
{(resizeRef) => (
<div
ref={(ref) => {
this.setChildContentRef(ref);
resizeRef(ref);
}}
>
<div className={childrenClasses} css={cssChildrenStyles}>
{childrenContent}
{(resizeRef) => {
this.resizeRef = resizeRef;
return (
<div ref={this.observerRef}>
<div className={childrenClasses} css={cssChildrenStyles}>
{childrenContent}
</div>
</div>
</div>
)}
);
}}
</EuiResizeObserver>
</div>
</Element>
Expand Down
3 changes: 3 additions & 0 deletions upcoming_changelogs/6031.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**Bug fixes**

- Fixed drag and drop interactions on EuiAccordion elements