From f7805dfea86f7af65fab15b0e22c2affca6a3168 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 29 Apr 2022 14:38:46 +0200 Subject: [PATCH] scaffolder: add wrapper to TemplateEditorForm to handle overflow Signed-off-by: Patrik Oldsberg --- .../TemplateEditor/TemplateEditor.tsx | 47 +++++++------------ .../TemplateEditor/TemplateEditorForm.tsx | 44 ++++++++++++----- 2 files changed, 51 insertions(+), 40 deletions(-) diff --git a/plugins/scaffolder/src/components/TemplateEditorPage/TemplateEditor/TemplateEditor.tsx b/plugins/scaffolder/src/components/TemplateEditorPage/TemplateEditor/TemplateEditor.tsx index bd12efa9b8..baf8ebf3f9 100644 --- a/plugins/scaffolder/src/components/TemplateEditorPage/TemplateEditor/TemplateEditor.tsx +++ b/plugins/scaffolder/src/components/TemplateEditorPage/TemplateEditor/TemplateEditor.tsx @@ -26,17 +26,8 @@ import { TemplateEditorTextArea } from './TemplateEditorTextArea'; const useStyles = makeStyles({ // Reset and fix sizing to make sure scrolling behaves correctly - rootWrapper: { - gridArea: 'pageContent', - position: 'relative', - width: '100%', - }, root: { - position: 'absolute', - top: 0, - bottom: 0, - left: 0, - right: 0, + gridArea: 'pageContent', display: 'grid', gridTemplateAreas: ` @@ -75,25 +66,23 @@ export const TemplateEditor = (props: { return ( -
-
-
- -
-
- -
-
- -
-
- -
-
-
+
+
+ +
+
+ +
+
+ +
+
+ +
+
); diff --git a/plugins/scaffolder/src/components/TemplateEditorPage/TemplateEditor/TemplateEditorForm.tsx b/plugins/scaffolder/src/components/TemplateEditorPage/TemplateEditor/TemplateEditorForm.tsx index a9e0182317..2e675bce0a 100644 --- a/plugins/scaffolder/src/components/TemplateEditorPage/TemplateEditor/TemplateEditorForm.tsx +++ b/plugins/scaffolder/src/components/TemplateEditorPage/TemplateEditor/TemplateEditorForm.tsx @@ -15,6 +15,7 @@ */ import { useApiHolder } from '@backstage/core-plugin-api'; import { JsonObject, JsonValue } from '@backstage/types'; +import { makeStyles } from '@material-ui/core/styles'; import React, { Component, ReactNode, useMemo, useState } from 'react'; import useDebounce from 'react-use/lib/useDebounce'; import yaml from 'yaml'; @@ -25,6 +26,22 @@ import { createValidator } from '../../TemplatePage'; import { useDirectoryEditor } from './DirectoryEditorContext'; import { useDryRun } from './DryRunContext'; +const useStyles = makeStyles({ + containerWrapper: { + position: 'relative', + width: '100%', + height: '100%', + }, + container: { + position: 'absolute', + top: 0, + bottom: 0, + left: 0, + right: 0, + overflow: 'auto', + }, +}); + interface ErrorBoundaryProps { invalidator: unknown; setErrorText(errorText: string | undefined): void; @@ -83,6 +100,7 @@ export function TemplateEditorForm(props: TemplateEditorFormProps) { setErrorText, fieldExtensions = [], } = props; + const classes = useStyles(); const apiHolder = useApiHolder(); const [steps, setSteps] = useState(); @@ -159,17 +177,21 @@ export function TemplateEditorForm(props: TemplateEditorFormProps) { } return ( - - onUpdate(e.formData)} - onReset={() => onUpdate({})} - finishButtonLabel={onDryRun && 'Try It'} - onFinish={onDryRun && (() => onDryRun(data))} - /> - +
+
+ + onUpdate(e.formData)} + onReset={() => onUpdate({})} + finishButtonLabel={onDryRun && 'Try It'} + onFinish={onDryRun && (() => onDryRun(data))} + /> + +
+
); }