act() does not flush updates scheduled before it, so a following fireEvent's update is deferred too
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 72/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- react, testing-qa, typescript
- Bereich
- testing
Rechercherichtung
Start by tracing how Redact schedules state updates and flushes them when the outermost act() scope exits; the issue does not name implementation files or tests. Reproduce the case in the issue with a focus update before fireEvent.click, then compare the immediate state with the supplied React results. Done means pending updates are reflected synchronously when act() returns, including updates queued before it began.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Version: @tanstack/redact 0.2.2
If a state update is scheduled outside act() and then an event runs inside act(), React's act flushes both before it returns. Redact flushes neither: both updates land one microtask later. A click on its own is flushed synchronously, so this only shows up when an update is already pending.
The common case: a test calls element.focus() (whose onFocus sets state, e.g. a tooltip trigger opening on focus) and then fireEvent.click(element). Assertions right after the click see the old state under Redact.
Repro (Vitest + jsdom + Testing Library)
import { render, fireEvent } from "@testing-library/react";
import * as React from "react";
function App() {
const [focused, setFocused] = React.useState(false);
const [open, setOpen] = React.useState(true);
return (
<button
data-focused={String(focused)}
onFocus={() => setFocused(true)}
onClick={() => setOpen((o) => !o)}
>
{open ? "open" : "closed"}
</button>
);
}
it("act flushes an update that was scheduled before it", async () => {
const { getByRole } = render(<App />);
const button = getByRole("button");
button.focus(); // onFocus -> setState, outside act
fireEvent.click(button); // wrapped in act by Testing Library
expect(button.textContent).toBe("closed");
expect(button.dataset.focused).toBe("true");
});
| state read | right after fireEvent.click |
after await Promise.resolve() |
|---|---|---|
| React 19 | closed / focused true |
closed / true |
| Redact 0.2.2 | open / focused false |
closed / true |
| Redact, click without prior focus | closed |
closed |
Expected
Like React: leaving the outermost act() scope flushes all pending work, including updates queued before the scope started.
Found in a TanStack Start app: two shell tests (sidebar toggle and detail panel with base-ui tooltip triggers) focus the trigger, click it and assert the new state and the focus hand-off synchronously. They pass under React and fail under Redact; with an extra await they pass.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 537
- Forks
- 22
- Ø Merge
- 1 Std. 57 Min.
- Gemergte PRs (30 T.)
- 20
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus TanStack/redact
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 90/100
TanStack/redact#67 · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in TanStack/redact
Ähnliche Issues
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 61/100
lingdojo/kana-dojo#33465 · 1 Kommentar · 5 Reaktionen ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
opensheetmusicdisplay/opensheetmusicdisplay#1885 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
Maintainer antworten meist innerhalb von 1 Tag
-
Time zone picker still shows America/Winnipeg as -06:00 after Manitoba’s move to permanent UTC-5Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
home-assistant/frontend#55537 ·
Maintainer antworten meist innerhalb von 1 Tag
-
What's New sheet: inline rows join title and summary with no space in copied/accessibility textOffenneeds-triage
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 82/100
manaflow-ai/cmux#31347 ·
Maintainer antworten meist innerhalb von 1 Tag