Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

PromptInput rejects every file when accept lists file extensions (".xlsx")

Đang mở Phù hợp với người mới
#501 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@HardMax71 đang làm issue này rồi.

Từ ngày 2/10/2026.

  • #502 của @HardMax71 — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
83/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
react, typescript
Lĩnh vực
frontend

Hướng nghiên cứu

Đọc packages/elements/src/prompt-input.tsx, đặc biệt là matchesAccept quanh các dòng 555–576, nơi các mẫu accept được so sánh. Kiểm tra việc tái hiện issue bằng một tệp .xlsx có kiểu rỗng và hành vi lọc tệp hiện có đối với các mẫu MIME. Được xem là hoàn tất khi các giá trị accept dựa trên phần mở rộng cho phép các tệp khớp được thông qua add, thao tác dán và thả, mà không làm hỏng việc lọc theo kiểu MIME.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

PromptInput passes accept to its hidden file input, where extension entries like .xlsx or .csv are valid. The filter that runs afterwards (matchesAccept) only understands type/* and exact MIME types, so an extension entry never matches. With accept=".xlsx" the file dialog offers the spreadsheet, then add rejects it: onError fires with code: "accept" ("No files match the accepted types."), or nothing happens without onError. Paste and drop use the same filter.

I use extensions because the browser often reports an empty or generic type ("" or application/octet-stream) for .md, .csv or Office files, depending on the OS.

Repro (registry main 6a9d5b1, Chrome):

const file = new File(["sheet"], "report.xlsx", { type: "" });

const AddButton = () => {
  const attachments = usePromptInputAttachments();
  return (
    <button onClick={() => attachments.add([file])} type="button">
      Add
    </button>
  );
};

<PromptInput accept=".xlsx" onError={console.log} onSubmit={() => {}}>
  <PromptInputBody>
    <AddButton />
    <PromptInputTextarea />
  </PromptInputBody>
</PromptInput>;

Expected: the file is added, as the native accept attribute allows it.
Actual: onError is called with { code: "accept" } and nothing is added.

Cause: prompt-input.tsx#L555-L576 compares every pattern that does not end in /* with f.type, and a pattern starting with "." never equals a MIME type. It came in with #279, which replaced the old fallback that returned true for anything except image/*.

Ngôn ngữ chính
TypeScript
Star
2.5k
Fork
290
Merge trung bình
20 phút
Pull request đã merge (30 ngày)
3

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của vercel/ai-elements

Tất cả issue của vercel/ai-elements

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.