From d3d1fdf4a0c49ab3f600a60a1c5e0c7c2fe0fedb Mon Sep 17 00:00:00 2001 From: Martin Krulis Date: Mon, 30 Oct 2017 17:55:36 +0100 Subject: [PATCH] Fixed source viewer dialog box to use flex CSS instead of broken JS height settings. --- .../SourceCodeViewer/SourceCodeViewer.js | 27 +++---- .../SourceCodeViewerContainer.js | 73 +++++-------------- .../SourceCodeViewerContainer/sourceCode.less | 30 +++++++- 3 files changed, 58 insertions(+), 72 deletions(-) diff --git a/src/components/helpers/SourceCodeViewer/SourceCodeViewer.js b/src/components/helpers/SourceCodeViewer/SourceCodeViewer.js index 386d93089..3dd20c8ee 100644 --- a/src/components/helpers/SourceCodeViewer/SourceCodeViewer.js +++ b/src/components/helpers/SourceCodeViewer/SourceCodeViewer.js @@ -32,27 +32,24 @@ const getMode = ext => { }; const SourceCodeViewer = ( - { name, content = '', lineNumbers = true, height }, + { name, content = '', lineNumbers = true }, { userSettings: { vimMode = false, darkTheme = false } } ) => - height - ? - : null; + ; SourceCodeViewer.propTypes = { name: PropTypes.string.isRequired, content: PropTypes.string, - lineNumbers: PropTypes.bool, - height: PropTypes.number + lineNumbers: PropTypes.bool }; SourceCodeViewer.contextTypes = { diff --git a/src/containers/SourceCodeViewerContainer/SourceCodeViewerContainer.js b/src/containers/SourceCodeViewerContainer/SourceCodeViewerContainer.js index 69bcebb95..870cb6e47 100644 --- a/src/containers/SourceCodeViewerContainer/SourceCodeViewerContainer.js +++ b/src/containers/SourceCodeViewerContainer/SourceCodeViewerContainer.js @@ -16,8 +16,6 @@ import SourceCodeViewer from '../../components/helpers/SourceCodeViewer'; import styles from './sourceCode.less'; class SourceCodeViewerContainer extends Component { - state = { height: null }; - componentWillMount() { const { fileId, loadAsync } = this.props; if (fileId !== null) { @@ -31,45 +29,13 @@ class SourceCodeViewerContainer extends Component { } } - onModalEntered() { - if (this.state.height === null) { - const { headerRef, bodyRef, footerRef } = this; - const height = - window.innerHeight - - headerRef.clientHeight - - bodyRef.clientHeight - - footerRef.clientHeight; - this.setState({ height }); - } - } - - onModalEnteredWhileLoading() { - if (this.state.height === null) { - const { loadingHeaderRef, loadingBodyRef, loadingFooterRef } = this; - const height = - window.innerHeight - - loadingHeaderRef.clientHeight - - loadingBodyRef.clientHeight - - loadingFooterRef.clientHeight; - this.setState({ height }); - } else { - // console.log('already has height', this.state.height); - } - } - render() { const { show, onHide, download, file, content } = this.props; - const { height } = this.state; return ( this.onModalEnteredWhileLoading()} - > -
(this.loadingHeaderRef = header)}> + +
{' '} @@ -80,12 +46,14 @@ class SourceCodeViewerContainer extends Component {
-
(this.loadingBodyRef = body)}> +
- +
+ +
-
(this.loadingFooterRef = footer)}> +