diff --git a/awx/ui_next/src/components/CodeMirrorInput/CodeMirrorInput.jsx b/awx/ui_next/src/components/CodeMirrorInput/CodeMirrorInput.jsx index 2ce36f9a7d..d945462987 100644 --- a/awx/ui_next/src/components/CodeMirrorInput/CodeMirrorInput.jsx +++ b/awx/ui_next/src/components/CodeMirrorInput/CodeMirrorInput.jsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useState, useEffect } from 'react'; import { oneOf, bool, number, string, func } from 'prop-types'; import { Controlled as ReactCodeMirror } from 'react-codemirror2'; import styled from 'styled-components'; @@ -67,6 +67,20 @@ function CodeMirrorInput({ fullHeight, className, }) { + // Workaround for CodeMirror bug: If CodeMirror renders in a modal on the + // modal's initial render, it appears as an empty box due to mis-calculated + // element height. Forcing an initial render before mounting + // fixes this. + const [isInitialized, setIsInitialized] = useState(false); + useEffect(() => { + if (!isInitialized) { + setIsInitialized(true); + } + }, [isInitialized]); + if (!isInitialized) { + return
; + } + return ( ); } FieldTooltip.propTypes = { - content: node.isRequired, + content: node, +}; +FieldTooltip.defaultProps = { + content: null, }; export default FieldTooltip; diff --git a/awx/ui_next/src/components/FormField/FormField.jsx b/awx/ui_next/src/components/FormField/FormField.jsx index 49d77cfae3..c94c370e47 100644 --- a/awx/ui_next/src/components/FormField/FormField.jsx +++ b/awx/ui_next/src/components/FormField/FormField.jsx @@ -1,18 +1,8 @@ import React from 'react'; import PropTypes from 'prop-types'; import { useField } from 'formik'; -import { - FormGroup, - TextInput, - TextArea, - Tooltip, -} from '@patternfly/react-core'; -import { QuestionCircleIcon as PFQuestionCircleIcon } from '@patternfly/react-icons'; -import styled from 'styled-components'; - -const QuestionCircleIcon = styled(PFQuestionCircleIcon)` - margin-left: 10px; -`; +import { FormGroup, TextInput, TextArea } from '@patternfly/react-core'; +import FieldTooltip from './FieldTooltip'; function FormField(props) { const { @@ -40,15 +30,7 @@ function FormField(props) { isValid={isValid} label={label} > - {tooltip && ( - - - - )} +