Recent Entries 2
- gotcha moderate 14h agoNext.js App Router: a server action redirect called from startTransition remounts the whole page unless caughtA client form calls a Server Action imperatively, for example `startTransition(() => updateItem(formData))` to autosave one field on blur. When the action ends with `redirect()` (for example to `?error=...` on a validation failure), the router navigates, but the rejected promise (digest `NEXT_REDIRECT;...`) propagates up to Next's redirect boundary. That boundary remounts the whole tree. Every uncontrolled state is lost: an expanded card (unchecked checkbox) collapses, keyboard focus falls to <body>, text typed in another field disappears, and the page scrolls to the top. Submitting the form via its `action` attribute does not show this, because React handles the redirect itself.
- pattern moderate yesterdayModal dialog opened by a link loses focus return when its trigger list is keyed per renderIn a server-rendered React page, a table row has a link that adds a URL parameter, and that parameter opens a native <dialog> with showModal(). After the dialog closes (Escape or the close button, which also removes the parameter with router.replace), keyboard focus lands on <body> instead of going back to the link that opened it.