-
Notifications
You must be signed in to change notification settings - Fork 4k
[fix] Fix upload button functionality after drag-drop and delete in st.chat_input
#13556
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] Fix upload button functionality after drag-drop and delete in st.chat_input
#13556
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
✅ PR preview is ready!
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
st.chat_input
fd1e739 to
aa61cf0
Compare
SummaryThis PR fixes a bug where the file upload button in Key changes:
Code QualityStrengths:
Minor observations:
Code locations reviewed:
Test CoverageE2E Test (st_chat_input_test.py lines 1763-1828):
Frontend Unit Tests:
Backwards Compatibility✅ No breaking changes
Security & Risk✅ No security concerns identified
Risk assessment: Low
Recommendations
VerdictAPPROVED: This is a well-implemented fix for a real user-facing bug. The approach follows React best practices, the E2E test coverage is comprehensive, and there are no backwards compatibility or security concerns. The code is ready for merge. This is an automated AI review. Please verify the feedback and use your judgment. |
There was a problem hiding this 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 bug where the file upload button in st.chat_input would stop working after drag-dropping a file and then deleting it. The fix refactors the upload button to use its own dropzone instance and implements a reset mechanism using a counter to force component remounting when files are cleared.
Changes:
- Refactored
ChatFileUploadButtonto create its own dropzone instance instead of receiving shared props from parent - Added
dropzoneResetCounterstate inChatInputto force re-render/remount of dropzone components when files are cleared - Disabled File System Access API (
useFsAccessApi: false) for consistent behavior across dropzone instances - Added comprehensive E2E test verifying upload button functionality after drag-drop and delete cycle
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
frontend/lib/src/components/widgets/ChatInput/fileUpload/ChatFileUploadButton.tsx |
Refactored to use its own useDropzone hook with onDrop, multiple, accept, and maxSize props instead of receiving getRootProps/getInputProps from parent; added useFsAccessApi: false configuration |
frontend/lib/src/components/widgets/ChatInput/ChatInput.tsx |
Added dropzoneResetCounter state to force component remounting on file clear; updated deleteFile and submitChatInput to increment counter when all files are cleared; added key={dropzoneResetCounter} to ChatFileUploadButton; configured useFsAccessApi: false in main dropzone |
e2e_playwright/st_chat_input_test.py |
Added test_upload_button_works_after_drag_drop_and_delete test that simulates drag-drop using DataTransfer, verifies file upload, deletes the file, and confirms upload button still works correctly |
frontend/lib/src/components/widgets/ChatInput/fileUpload/ChatFileUploadButton.tsx
Show resolved
Hide resolved
aa61cf0 to
79424be
Compare
📈 Frontend coverage change detectedThe frontend unit test (vitest) coverage has increased by 0.0100%
✅ Coverage change is within normal range. |
2b3d996 to
8623c4d
Compare
…upload button Move useDropzone hook into ChatFileUploadButton so it can be properly reset via React key when files are deleted. This fixes a react-dropzone bug where the file input becomes unresponsive after files are removed. Add e2e test that validates the upload button still works after a drag-drop + delete cycle. See: react-dropzone/react-dropzone#972
Increment dropzoneResetCounter directly at call sites where files are cleared rather than detecting the transition via useEffect. This follows the 'You Might Not Need an Effect' principle from React docs.
Add documentation comment explaining why useFsAccessApi: false is set in ChatFileUploadButton, referencing issue #6176 for context. Resolves comment 1
Add documentation comment explaining why useFsAccessApi: false is set in the main ChatInput dropzone config, referencing issue #6176. Resolves comment 2
Change marker from only_browser("chromium") to skip_browser("webkit") to run the DataTransfer drag-drop test in both Chromium and Firefox.
Resolves comment 3
Add assertion to verify the originally deleted file doesn't reappear after uploading a new file, following E2E best practices. Resolves comment 4
Remove explicit viewport size setting since this test doesn't depend on layout behavior - it's purely testing file upload mechanics. Resolves comment 5
Revert skip_browser(webkit) back to only_browser(chromium) since DataTransfer dispatch_event has inconsistent behavior in Firefox as well. Added comment explaining the limitation.
The DataTransfer dispatch_event approach is unreliable across browsers. Using button uploads still tests the same react-dropzone reset bug (file input becomes unresponsive after files are deleted).
8623c4d to
2600482
Compare
The upload button test was failing because 'second_upload.txt' (17 chars) was being truncated by the UI's 16-character filename limit, causing the get_by_text() locator to fail. Changed to 'first.txt' and 'second.txt'.

Describe your changes
Fixed an issue where the file upload button in
st.chat_inputwould stop working after drag-dropping a file and then deleting it. The fix includes:ChatFileUploadButtonto use its own dropzone instance instead of sharing propsTesting Plan
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.