Skip to content

Commit

Permalink
fix: Remove additional Editor scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Sep 27, 2024
1 parent d7edbd0 commit 3e2ae25
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
11 changes: 2 additions & 9 deletions editor.planx.uk/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
"react-hooks",
"simple-import-sort",
"jsx-a11y",
"testing-library",
"jest"
"testing-library"
],
"extends": [
"eslint:recommended",
"plugin:jsx-a11y/recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"plugin:jest/recommended"
"prettier"
],
"rules": {
"react-hooks/rules-of-hooks": "error",
Expand Down Expand Up @@ -89,11 +87,6 @@
],
"no-nested-ternary": "error"
},
"settings": {
"jest": {
"version": 27
}
},
"overrides": [
{
"files": [
Expand Down
3 changes: 3 additions & 0 deletions editor.planx.uk/src/components/TestEnvironmentBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ import { visuallyHidden } from "@mui/utils";
import { useStore } from "pages/FlowEditor/lib/store";
import React from "react";

import { HEADER_HEIGHT_EDITOR } from "./Header";

const TestEnvironmentWarning = styled(Box)(({ theme }) => ({
backgroundColor: theme.palette.background.paper,
color: theme.palette.text.primary,
justifyContent: "space-between",
alignItems: "center",
padding: "0.2em 0",
minHeight: HEADER_HEIGHT_EDITOR,
}));

const TestEnvironmentBanner: React.FC = () => {
Expand Down
17 changes: 14 additions & 3 deletions editor.planx.uk/src/pages/FlowEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ import Sidebar from "./components/Sidebar";
import { useStore } from "./lib/store";
import useScrollControlsAndRememberPosition from "./lib/useScrollControlsAndRememberPosition";

const EditorContainer = styled(Box)(() => ({
const EditorContainer = styled(Box, {
shouldForwardProp: (prop) => prop !== "isTestEnvBannerVisible",
})<{ isTestEnvBannerVisible?: boolean }>(({ isTestEnvBannerVisible }) => ({
display: "flex",
alignItems: "stretch",
overflow: "hidden",
flexGrow: 1,
maxHeight: `calc(100vh - ${HEADER_HEIGHT_EDITOR}px)`,
maxHeight: isTestEnvBannerVisible
? `calc(100vh - ${HEADER_HEIGHT_EDITOR * 2}px)`
: `calc(100vh - ${HEADER_HEIGHT_EDITOR}px)`,
}));

const FlowEditor = () => {
Expand All @@ -27,8 +31,15 @@ const FlowEditor = () => {
useScrollControlsAndRememberPosition(scrollContainerRef);
const showSidebar = useStore((state) => state.showSidebar);

const isTestEnvBannerVisible = useStore(
(state) => state.isTestEnvBannerVisible,
);

return (
<EditorContainer id="editor-container">
<EditorContainer
id="editor-container"
isTestEnvBannerVisible={isTestEnvBannerVisible}
>
<Box
sx={{
display: "flex",
Expand Down
2 changes: 0 additions & 2 deletions editor.planx.uk/src/pages/layout/AuthenticatedLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Box from "@mui/material/Box";
import { containerClasses } from "@mui/material/Container";
import { styled } from "@mui/material/styles";
import EditorNavMenu from "components/EditorNavMenu";
import { HEADER_HEIGHT_EDITOR } from "components/Header";
import RouteLoadingIndicator from "components/RouteLoadingIndicator";
import React, { PropsWithChildren } from "react";
import { DndProvider } from "react-dnd";
Expand All @@ -23,7 +22,6 @@ const DashboardContainer = styled(Box)(({ theme }) => ({
display: "flex",
flexDirection: "row",
width: "100%",
minHeight: `calc(100vh - ${HEADER_HEIGHT_EDITOR}px)`,
overflow: "hidden",
[`& > .${containerClasses.root}`]: {
paddingTop: theme.spacing(3),
Expand Down

0 comments on commit 3e2ae25

Please sign in to comment.