Skip to content

Commit

Permalink
[APM] Context Tabs jumping height fix (#32351) (#32410)
Browse files Browse the repository at this point in the history
* [APM] fixes #18144 by setting the container min-height to the tab with the largest rendered height

* [APM] moved HeightRetainer into its own shared component module
  • Loading branch information
ogupte authored Mar 4, 2019
1 parent c44dcb0 commit aa008e7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
import { Transaction } from '../../../../../typings/es_schemas/Transaction';
import { IUrlParams } from '../../../../store/urlParams';
import { px, units } from '../../../../style/variables';
import { HeightRetainer } from '../../../shared/HeightRetainer';
import {
getPropertyTabNames,
PropertiesTable
Expand Down Expand Up @@ -67,7 +68,7 @@ export function TransactionPropertiesTable({
const isTimelineTab = currentTab.key === timelineTab.key;

return (
<div>
<HeightRetainer>
<EuiTabs>
{tabs.map(({ key, label }) => {
return (
Expand Down Expand Up @@ -108,6 +109,6 @@ export function TransactionPropertiesTable({
/>
</TableContainer>
)}
</div>
</HeightRetainer>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React, { useEffect, useRef } from 'react';

export const HeightRetainer: React.SFC = props => {
const containerElement = useRef<HTMLDivElement>(null);
const minHeight = useRef<number>(0);

useEffect(() => {
if (containerElement.current) {
const currentHeight = containerElement.current.clientHeight;
if (minHeight.current < currentHeight) {
minHeight.current = currentHeight;
}
}
});

return (
<div
{...props}
ref={containerElement}
style={{ minHeight: minHeight.current }}
/>
);
};

0 comments on commit aa008e7

Please sign in to comment.