Change appearance of parameters in task details (#1017)

This commit is contained in:
Shuchang Zheng
2024-10-21 09:29:49 -07:00
committed by GitHub
parent 9a9057ccf7
commit 442f70c58e
5 changed files with 106 additions and 88 deletions

View File

@@ -1,10 +1,22 @@
import { useLayoutEffect, useRef } from "react";
import { ChangeEventHandler, useLayoutEffect, useRef } from "react";
import { Textarea } from "@/components/ui/textarea";
import { cn } from "@/util/utils";
type Props = React.ComponentPropsWithoutRef<typeof Textarea>;
type Props = {
value: string;
onChange?: ChangeEventHandler<HTMLTextAreaElement>;
className?: string;
readOnly?: boolean;
placeholder?: string;
};
function AutoResizingTextarea(props: Props) {
function AutoResizingTextarea({
value,
onChange,
className,
readOnly,
placeholder,
}: Props) {
const ref = useRef<HTMLTextAreaElement>(null);
useLayoutEffect(() => {
@@ -25,12 +37,15 @@ function AutoResizingTextarea(props: Props) {
return (
<Textarea
{...props}
value={value}
onChange={onChange}
readOnly={readOnly}
placeholder={placeholder}
ref={ref}
onKeyDown={setSize}
onInput={setSize}
rows={1}
className={cn("min-h-0 resize-none overflow-y-hidden", props.className)}
className={cn("min-h-0 resize-none overflow-y-hidden", className)}
/>
);
}