-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
2 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
x-pack/plugins/apm/public/components/shared/HeightRetainer/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} | ||
/> | ||
); | ||
}; |