fix: Response Pane height context restore issue in some cases (#17750)

This commit is contained in:
Hetu Nandu 2022-10-20 18:23:47 +05:30 committed by GitHub
parent ddff993722
commit ff15074f82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,7 @@
import { Layers } from "constants/Layers";
import React, { useState, useEffect, RefObject } from "react";
import styled, { css } from "styled-components";
import { ActionExecutionResizerHeight } from "pages/Editor/APIEditor/constants";
export const ResizerCSS = css`
width: 100%;
@ -30,15 +31,20 @@ type ResizerProps = {
function Resizer(props: ResizerProps) {
const [mouseDown, setMouseDown] = useState(false);
const [height, setHeight] = useState(
props.panelRef.current?.getBoundingClientRect().height || 0,
props.initialHeight ||
props.panelRef.current?.getBoundingClientRect().height ||
ActionExecutionResizerHeight,
);
// On mount and update, set the initial height of the component
useEffect(() => {
if (!props.initialHeight) return;
const panel = props.panelRef.current;
if (!panel) return;
panel.style.height = `${props.initialHeight}px`;
setHeight(props.initialHeight);
if (height !== props.initialHeight) {
setHeight(props.initialHeight);
}
}, [props.initialHeight]);
const handleResize = (movementY: number) => {