Synthetic events drop non-enumerable fields (clipboardData/dataTransfer from Testing Library are undefined)
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 78/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- javascript, react, typescript
Direção de pesquisa
Comece em src/dom/synthetic-event.ts, em createSyntheticEvent, e leia como ele copia os campos do evento nativo. Reproduza os valores ausentes de clipboardData ou dataTransfer com o exemplo de Vitest e Testing Library da issue. O trabalho estará concluído quando os handlers receberem esses valores nos testes e o comportamento atual dos eventos sintéticos continuar funcionando.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Version: @tanstack/redact 0.2.2
createSyntheticEvent (src/dom/synthetic-event.ts) copies the native event's fields with for (const key in native). That only sees enumerable properties. Own properties defined with Object.defineProperty (non-enumerable by default) are dropped, so the handler gets undefined where React hands over the value.
In real browsers this is fine for native events: WebIDL attributes such as ClipboardEvent.clipboardData and DragEvent.dataTransfer are enumerable accessors on the prototype (checked in Chromium). It breaks for:
- Testing Library / jsdom:
fireEvent.paste(el, { clipboardData })andfireEvent.drop(el, { dataTransfer })assign those fields withObject.defineProperty, because jsdom has noClipboardEvent/DragEventdata. Paste and drop tests that pass under React fail under Redact. - Any library or app code that dispatches a plain
Eventand attaches data the same way.
Repro (Vitest + jsdom + Testing Library)
import { render, fireEvent } from "@testing-library/react";
it("handlers see non-enumerable event fields", () => {
let pasted: unknown;
const { getByRole } = render(
<textarea onPaste={(e) => { pasted = e.clipboardData?.getData("text/plain"); }} />,
);
fireEvent.paste(getByRole("textbox"), { clipboardData: { getData: () => "hello" } });
let dropped: unknown;
const { container } = render(<div onDrop={(e) => { dropped = e.dataTransfer?.getData("text"); }} />);
const ev = new Event("drop", { bubbles: true });
Object.defineProperty(ev, "dataTransfer", { value: { getData: () => "dropped" } });
container.firstChild!.dispatchEvent(ev);
expect(pasted).toBe("hello");
expect(dropped).toBe("dropped");
});
pasted |
dropped |
|
|---|---|---|
| React 19 | "hello" |
"dropped" |
| Redact 0.2.2 | undefined |
undefined |
Suggestion
Also copy own non-enumerable properties (Object.getOwnPropertyNames(native)), or read fields lazily from nativeEvent (a getter or Proxy fallback) the way React's per-interface getters read nativeEvent.clipboardData / dataTransfer directly.
Found while running a TanStack Start app's component tests (chat composer paste and image drop) under Redact.
- Linguagem predominante
- TypeScript
- Estrelas
- 408
- Forks
- 13
- Merge médio
- 1h 44min
- PRs com merge (30d)
- 21
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de TanStack/redact
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 90/100
TanStack/redact#67 · 1 reação ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 82/100
Mantenedores costumam responder em até 1 dia
-
Bug: jsx runtime doesn't apply defaultProps (breaks Recharts 2: "Could not find xAxis by id")Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
TanStack/redact#58 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
Todas as issues de TanStack/redact
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
lichess-org/lila#22324 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
[Feature Request] [Web] Expose kvCacheQuantizationBits in the onnxruntime-web WebGPU EP optionsAbertaep:WebGPU platform:web quantization
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
microsoft/onnxruntime#33752 ·
Mantenedores costumam responder em até 2 dias
-
[Skill Bug]: entra-agent-id: inaccurate blueprint permission inheritance and parent token sub claimAbertabug entra-agent-id
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
microsoft/GitHub-Copilot-for-Azure#3467 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
fix(worker): keep normal prepare waiting states failure-freeTalvez já em andamento @LichKing-2234 assumiu hoje. Abertaagent:codex priority:P1
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
AgoraIO-Extensions/agent-infra#3745 ·
Mantenedores costumam responder em até 1 dia
-
The five-line work window can drop its oldest line: the per-line byte share ignores the JSON framingTalvez já em andamento @Eapp1e assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
makecindy/cindy#7973 · 1 comentário ·
Mantenedores costumam responder em até 1 dia