Merge pull request #4680 from appsmithorg/ui/perf/optimize-expensive-style-calc-evalauatedValuePopup/4679
Memoize the evaluate popup placement value
This commit is contained in:
commit
83b44b30b6
|
|
@ -1,4 +1,4 @@
|
|||
import React, { memo, useRef, useState } from "react";
|
||||
import React, { memo, useMemo, useRef, useState } from "react";
|
||||
import styled from "styled-components";
|
||||
import _ from "lodash";
|
||||
import Popper from "pages/Editor/Popper";
|
||||
|
|
@ -314,13 +314,15 @@ function EvaluatedValuePopup(props: Props) {
|
|||
const [contentHovered, setContentHovered] = useState(false);
|
||||
|
||||
const wrapperRef = useRef<HTMLDivElement>(null);
|
||||
let placement: Placement = "left-start";
|
||||
if (wrapperRef.current) {
|
||||
const boundingRect = wrapperRef.current.getBoundingClientRect();
|
||||
if (boundingRect.left < theme.evaluatedValuePopup.width) {
|
||||
placement = "right-start";
|
||||
const placement: Placement = useMemo(() => {
|
||||
if (wrapperRef.current) {
|
||||
const boundingRect = wrapperRef.current.getBoundingClientRect();
|
||||
if (boundingRect.left < theme.evaluatedValuePopup.width) {
|
||||
return "right-start";
|
||||
}
|
||||
}
|
||||
}
|
||||
return "left-start";
|
||||
}, [wrapperRef.current]);
|
||||
|
||||
return (
|
||||
<Wrapper ref={wrapperRef}>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user