FileUpload Templated: Inconsistency in getFiles() and totalSize calculation during onSelect and onRemove events
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- next.js, react
- Lĩnh vực
- frontend
Hướng nghiên cứu
Bắt đầu với luồng sự kiện onSelect và onRemove của component FileUpload cũng như hành vi của getFiles() khi sử dụng headerTemplate hoặc itemTemplate. Tái hiện sự cố với React 18.3.1 và PrimeReact 10.9.7, sau đó xác minh rằng getFiles() phản ánh đồng bộ danh sách tệp đã cập nhật và các phép tính totalSize không còn yêu cầu setTimeout.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
When utilizing the FileUpload component with custom templates (headerTemplate, itemTemplate), managing the total file size state (totalSize) externally becomes inconsistent. The onSelect and onRemove events appear to fire asynchronously relative to the component's internal file list update.
Reproducer
No response
System Information
"react": "18.3.1",
"react-dom": "18.3.1",
"primereact": "^10.9.7",
Steps to reproduce the behavior
Steps to Reproduce:
Create a FileUpload component using the App Router in Next.js (client-side) with headerTemplate to display an external totalSize state managed by useState.
Implement onSelect and onRemove handlers that attempt to use fileUploadRef.current.getFiles() to accurately calculate the current total size.
Select a single file (File A). The displayed total size is incorrect (often 0 or delayed).
Select a second file (File B). The total size calculation often incorrectly duplicates the size of File A plus the size of File B (e.g., A + A + B), or only shows the size of File A.
Deleting File B sometimes synchronizes the size correctly, sometimes no
Expected behavior
fileUploadRef.current.getFiles() should reliably and synchronously reflect the updated list of files immediately after the onSelect or onRemove events have fired, allowing external state management to remain synchronized without requiring workarounds.
Current Workaround:
The only reliable way to achieve synchronization is by using setTimeout(syncTotalSize, 0) within the onSelect and onRemove handlers to defer the state update to the next event loop tick.
- Ngôn ngữ chính
- CSS
- Star
- 8.3k
- Fork
- 1.2k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của primefaces/primereact
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
primefaces/primereact#8552 ·
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
primefaces/primereact#8550 ·
-
Row checkbox selection tick is invisible in Landing Page Theme sectionCó thể đã có người làm @Prakash1185 đã nhận 150 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
primefaces/primereact#8545 ·
-
Dependency conflict between jspdf v4 and jspdf-autotable during npm installCó thể đã có người làm @Kamran92 đã nhận 165 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
primefaces/primereact#8537 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 58/100
primefaces/primereact#8551 ·
Tất cả issue của primefaces/primereact
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
bug from-studio
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
esengine/DeepSeek-Reasonix#14868 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] Web Player: Misalignment in lyrics toolbar with format dropdown ('Auto') and download iconĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
kushagrasinghx/BitChord#1269 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
beginner bug frontend
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
BistaDinesh03/critique#266 ·
Maintainer thường phản hồi trong vòng 1 ngày