Dispatched mouse events call onClick/onMouseDown on disabled buttons (React skips them)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 68/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript, react, typescript
- 领域
- frontend, testing-qa
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- TypeScript
- 星标
- 537
- 派生
- 22
- 平均合并
- 10 小时 27 分钟
- 30 天内合并 PR
- 40
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TanStack/redact 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 55/100
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
维护者通常 1 天内回复
相似的 Issue
-
Chip source filter and denial markers miss Storage rows when a Storage activity source is picked未关闭bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 77/100
omdsh-dev/DSH-better-sidebar#1141 ·
维护者通常 2 天内回复
-
desktop linux photos
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
Cleanup Setup可能已有人在做 @AlexanderKaran 今天认领。 未关闭documentation enhancement
难度 2/5 1-3 小时 新手友好度 64/100
e18e/framework-tracker#769 ·
维护者通常 1 天内回复
-
bug v2
难度 1/5 1 小时以内 新手友好度 88/100
modelcontextprotocol/servers#5483 ·
维护者通常 1 天内回复