dialog.showModal() moves focus to the first focusable element, so autoFocus on a textarea inside it does nothing
In React, a <dialog> that stays mounted and is opened with ref.current.showModal() ignores autoFocus on a textarea inside it: autoFocus only runs on mount, and showModal() then focuses the first focusable element in the dialog (often the header close button). Typed input ends up nowhere, and the textarea shows no value.
Fix: focus the field yourself right after opening:
useEffect(() => { const d = ref.current; if (open && !d.open) { d.showModal(); d.querySelector("textarea, input")?.focus(); } if (!open && d.open) d.close(); }, [open]);
Then remove the autoFocus props. Alternatively, put the autofocus attribute on the element you want focused, since the dialog focusing steps honor it, but that is easy to break when the dialog stays mounted between opens.