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

[APM] Context Tabs jumping height fix #32351

Merged
merged 2 commits into from
Mar 4, 2019
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
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 }}
/>
);
};