Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust prompt input height when minRows changes #3166

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/prompt-input/internal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const InternalPromptInput = React.forwardRef(
const minTextareaHeight = `calc(${LINE_HEIGHT} + ${tokens.spaceScaledXxs} * 2)`; // the min height of Textarea with 1 row
textareaRef.current.style.height = `min(max(${scrollHeight}, ${minTextareaHeight}), ${maxRowsHeight})`;
}
}, [maxRows, LINE_HEIGHT, PADDING]);
}, [minRows, maxRows, LINE_HEIGHT, PADDING]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since adjustTextarea callback doesn't use minRows, adding it as its dependency would be confusing.

For the same reason you should get a linter error like this:

image

We can either mute this eslint error and include a comment that clearly explains how changing the minRows affects the rows attribute on the underlying <textarea /> element which ultimately changes the scrollHeight

or simply move the minRows the the dependency array of useEffect at line 130:

useEffect(() => {
  adjustTextareaHeight();
}, [value, adjustTextareaHeight, maxRows, minRows, isCompactMode]


useEffect(() => {
const handleResize = () => {
Expand Down
Loading