Skip to content

Commit

Permalink
blop
Browse files Browse the repository at this point in the history
  • Loading branch information
actualwitch committed Dec 21, 2024
1 parent 08f6625 commit e0d0e00
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/pages/NewExperiment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,13 @@ const TextArea = (props: React.TextareaHTMLAttributes<HTMLTextAreaElement>) => {
const ref = useRef<HTMLTextAreaElement | null>(null);
useEffect(() => {
if (!ref.current) return;
let plannedHeight = 0;
ref.current.style.height = "inherit";
if (props.value) {
const docHeight = document.documentElement.clientHeight;
const contentScrollHeight = ref.current.scrollHeight;
plannedHeight = Math.min(Math.max(contentScrollHeight, 0), Math.floor(docHeight / 2));
}
ref.current.style.height = "inherit";
ref.current.style.height = `${plannedHeight}px`;
const plannedHeight = Math.min(Math.max(contentScrollHeight, 0), Math.floor(docHeight / 2));
ref.current.style.height = `${plannedHeight}px`;
}
}, [props.value]);
return <textarea {...props} ref={ref} />;
};
Expand Down

0 comments on commit e0d0e00

Please sign in to comment.