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

fix: Prompt input has incorrect height on first render when expanding split panel #2947

Merged
merged 1 commit into from
Oct 30, 2024

Conversation

YueyingLu
Copy link
Member

Description

Fix Prompt input has incorrect height on first render when expanding split panel. It is because the height is set to scrollHeight of the textarea Ref, but it can be 0 when it is in collapsed Split panel. The fix uses the 1 row height of textarea (1 line height + top&bottom padding) as the min height.

Related links, issue AWSUI-56326

How has this been tested?

Added integration test and run the fix though dev pipeline.
Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@YueyingLu YueyingLu requested a review from a team as a code owner October 29, 2024 14:00
@YueyingLu YueyingLu requested review from georgylobko and removed request for a team October 29, 2024 14:00
@YueyingLu YueyingLu changed the title Fix Prompt input has incorrect height on first render when expanding split panel fix: Prompt input has incorrect height on first render when expanding split panel Oct 29, 2024
Copy link

codecov bot commented Oct 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.25%. Comparing base (4ff710b) to head (42c6947).
Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #2947    +/-   ##
========================================
  Coverage   96.25%   96.25%            
========================================
  Files         769      769            
  Lines       21735    21736     +1     
  Branches     7441     7031   -410     
========================================
+ Hits        20920    20921     +1     
- Misses        762      807    +45     
+ Partials       53        8    -45     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

georgylobko
georgylobko previously approved these changes Oct 29, 2024
@@ -108,7 +108,8 @@ const InternalPromptInput = React.forwardRef(
textareaRef.current.style.height = 'auto';
const maxRowsHeight = `calc(${maxRows <= 0 ? 3 : maxRows} * (${LINE_HEIGHT} + ${PADDING} / 2) + ${PADDING})`;
const scrollHeight = `calc(${textareaRef.current.scrollHeight}px)`;
textareaRef.current.style.height = `min(${scrollHeight}, ${maxRowsHeight})`;
const minRowsHeight = `calc(${LINE_HEIGHT} + ${tokens.spaceScaledXxs} * 2)`; // the min height of Textarea with 1 line
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const minRowsHeight = `calc(${LINE_HEIGHT} + ${tokens.spaceScaledXxs} * 2)`; // the min height of Textarea with 1 line
const minTextareaHeight = `calc(${LINE_HEIGHT} + ${tokens.spaceScaledXxs} * 2)`;

@YueyingLu YueyingLu added this pull request to the merge queue Oct 30, 2024
Merged via the queue into main with commit 8f5431a Oct 30, 2024
37 checks passed
@YueyingLu YueyingLu deleted the prompt-input-height branch October 30, 2024 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants