Dispatched mouse events call onClick/onMouseDown on disabled buttons (React skips them)
Maintainer thường phản hồi trong vòng 1 ngày
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
- 68/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ệ
- javascript, react, typescript
- Lĩnh vực
- frontend, testing-qa
Hướng nghiên cứu
Start by reproducing the issue with the supplied Vitest, jsdom, and Testing Library example, then read React DOM's shouldPreventMouseEvent behavior and find the corresponding event-dispatch path in Redact. Done when dispatched mouse events do not call handlers on disabled button, input, select, or textarea elements, and the regression test passes.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Version: @tanstack/redact 0.2.5
A dispatched click on a disabled <button> calls its onClick under Redact. React doesn't: its event system skips mouse events (onClick, onMouseDown, onMouseUp, onDoubleClick, …) on disabled button, input, select and textarea elements (shouldPreventMouseEvent in React DOM).
Real user clicks are unaffected, because browsers don't deliver them to disabled form controls. But element.dispatchEvent(new MouseEvent("click")) and Testing Library's fireEvent.click do reach the element, so tests asserting that a disabled button does nothing fail under Redact.
Repro (Vitest + jsdom + Testing Library)
// @vitest-environment jsdom
import { render, fireEvent } from "@testing-library/react";
import { expect, it, vi } from "vitest";
it("does not call onClick on a disabled button", () => {
const onClick = vi.fn();
const onMouseDown = vi.fn();
const { getByRole } = render(
<button disabled onClick={onClick} onMouseDown={onMouseDown}>Send</button>
);
const button = getByRole("button");
fireEvent.click(button);
fireEvent.mouseDown(button);
button.dispatchEvent(new MouseEvent("click", { bubbles: true }));
expect(onClick).not.toHaveBeenCalled();
expect(onMouseDown).not.toHaveBeenCalled();
});
onClick calls |
onMouseDown calls |
|
|---|---|---|
| React 19 | 0 ✅ | 0 ✅ |
| Redact 0.2.5 | 2 ❌ | 1 ❌ |
Expected
Like React: don't dispatch mouse event handlers to a disabled button/input/select/textarea (or to handlers on the disabled element when the event targets it).
Found in a TanStack Start app: a test checks that a "send" button stays inert while an earlier send is still unclear (disabled set, then fireEvent.click). It passes under React and fails under Redact.
- Ngôn ngữ chính
- TypeScript
- Star
- 537
- Fork
- 22
- Merge trung bình
- 11 giờ 37 phút
- Pull request đã merge (30 ngày)
- 35
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
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 TanStack/redact
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
TanStack/redact#142 · 2 bình luận ·
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 85/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 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của TanStack/redact
Issue tương tự
-
[Text] Add Reading Time & Word Count Estimator for Reflection Notes in src/lib/text/reading-time.tsĐang mởarea:core beginner-friendly community contributions-welcome difficulty:easy enhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[fullsend] E2E: scorecard — filecheck GitLab entity metrics unavailable due to initialDelay timingĐang mởe2e-failure ready-to-code
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
redhat-developer/rhdh-plugin-export-overlays#4698 · 1 bình luận ·
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 88/100
devswha/herdr-web-ui#2884 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
b:minor bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
software-mansion/argent#1771 ·
Maintainer thường phản hồi trong vòng 1 ngày