Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@sfc-gh-lwilby
Copy link
Collaborator

Describe your changes

This PR addresses a regression where the logic for resetting the height of st.chat_input after submission was broken by some refactoring. It re-introduces the code to reset the scroll height to 0 after submit. The PR also adds an e2e test for the user interaction.

GitHub Issue Link (if applicable)

Fixes #12079

Testing Plan

  • E2E Tests ✅

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@snyk-io
Copy link
Contributor

snyk-io bot commented Aug 6, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@github-actions
Copy link
Contributor

github-actions bot commented Aug 6, 2025

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-12132/streamlit-1.47.1-py3-none-any.whl
🕹️ Preview app pr-12132.streamlit.app (☁️ Deploy here if not accessible)

@sfc-gh-lwilby sfc-gh-lwilby added security-assessment-completed Security assessment has been completed for PR change:bugfix PR contains bug fix implementation impact:users PR changes affect end users labels Aug 6, 2025
@sfc-gh-lwilby sfc-gh-lwilby marked this pull request as ready for review August 6, 2025 15:48
@lukasmasuch lukasmasuch requested a review from Copilot August 6, 2025 16:23
Copy link
Collaborator

@lukasmasuch lukasmasuch left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a regression in st.chat_input where the input field wasn't collapsing back to its compact state after message submission. The fix restores the auto-expand functionality by re-introducing logic to reset the textarea height after form submission.

Key changes:

  • Extended the useTextInputAutoExpand hook to provide a clearScrollHeight function
  • Added a call to reset the scroll height in the ChatInput component's submit handler
  • Added comprehensive e2e tests to verify the height reset behavior

Reviewed Changes

Copilot reviewed 3 out of 12 changed files in this pull request and generated 1 comment.

File Description
frontend/lib/src/hooks/useTextInputAutoExpand.ts Added clearScrollHeight function to reset textarea scroll height to 0
frontend/lib/src/components/widgets/ChatInput/ChatInput.tsx Added call to clearScrollHeight() in submit handler to reset input height
e2e_playwright/st_chat_input_test.py Added e2e test to verify chat input height resets properly after submission

chat_input = app.get_by_test_id("stChatInput").nth(0)
chat_input_area = chat_input.locator("textarea")

assert_snapshot(chat_input, name="st_chat_input-initial_compact_state")
Copy link

Copilot AI Aug 6, 2025

Choose a reason for hiding this comment

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

The snapshot naming follows the recommended convention 'st_command-test_description' as specified in the coding guidelines.

Copilot generated this review using guidance from repository custom instructions.
@sfc-gh-lwilby sfc-gh-lwilby merged commit 77f6a01 into develop Aug 6, 2025
37 checks passed
@sfc-gh-lwilby sfc-gh-lwilby deleted the fix/chat_input_reset_height_after_submit branch August 6, 2025 16:32
sfc-gh-lwilby added a commit that referenced this pull request Aug 12, 2025
## Describe your changes

This PR addresses a regression where the logic for resetting the height
of `st.chat_input` after submission was broken by some refactoring. It
re-introduces the code to reset the scroll height to 0 after submit. The
PR also adds an e2e test for the user interaction.

<!-- If it's a visual change, please include a screenshot or video! -->

## GitHub Issue Link (if applicable)

Fixes #12079

## Testing Plan

- E2E Tests ✅ 

---

**Contribution License Agreement**

By submitting this pull request you agree that all contributions to this
project are made under the Apache 2.0 license.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:bugfix PR contains bug fix implementation impact:users PR changes affect end users security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

st.chat_input does not revert to single-line height after multi-line input (Streamlit 1.47.1)

3 participants