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 ( { + // set survey initial values to parent form surveyFieldHelpers.setValue(initialValues); /* eslint-disable-next-line react-hooks/exhaustive-deps */ }, []); @@ -74,10 +79,6 @@ function SurveySubForm({ survey, initialValues, i18n }) { integer: NumberField, float: NumberField, }; - // This is a nested Formik form to perform validation on individual - // survey questions. When changes to the inner form occur (onBlur), the - // values for all questions are added to the outer form's `survey` field - // as a single object. return ( {({ values }) => ( diff --git a/awx/ui_next/src/components/ResourceAccessList/__snapshots__/DeleteRoleConfirmationModal.test.jsx.snap b/awx/ui_next/src/components/ResourceAccessList/__snapshots__/DeleteRoleConfirmationModal.test.jsx.snap index 795f398ba2..e66d8780df 100644 --- a/awx/ui_next/src/components/ResourceAccessList/__snapshots__/DeleteRoleConfirmationModal.test.jsx.snap +++ b/awx/ui_next/src/components/ResourceAccessList/__snapshots__/DeleteRoleConfirmationModal.test.jsx.snap @@ -322,7 +322,6 @@ exports[` should render initially 1`] = ` className="pf-c-backdrop" > should render initially 1`] = ` } } paused={false} - tag="div" >