-
Notifications
You must be signed in to change notification settings - Fork 273
Open
Description
Summary
When rendering a <textarea> and then conditionally rendering a sibling <line-number> before it (after the textarea ref becomes available), OpenTUI crashes with:
Error: Anchor does not exist
at insertBefore (Renderable.ts:1161:17)
This looks like React trying to insertBefore() into a <box> container, but the anchor resolution fails.
Environment
- Runtime: Bun
@opentui/core: 0.1.62@opentui/react: 0.1.62react: 19.2.3- OS: (fill in)
Steps to Reproduce
- Render a
<textarea>and store its instance via a callback ref. - Conditionally render
<line-number target={textareaInstance} />before the textarea once the ref is set.
Minimal repro:
const [target, setTarget] = useState<any>(null)
return (
<box flexDirection="row">
{target && <line-number target={target} />}
<textarea ref={setTarget} />
</box>
)Expected
mounts and attaches to the textarea without crashing.
Actual
Crash with Error: Anchor does not exist coming from insertBefore.
Notes / Suspected Cause
- On initial render, only <textarea> exists.
- After the ref sets state, React re-renders and attempts to insert before an existing child.
- The host implementation (or its internal children tracking) appears to mishandle insertBefore anchor resolution in this scenario.
Workarounds - Render <textarea> first (so gets appended when it becomes available), and use flexDirection="row-reverse" to keep line numbers on the left.
- Alternatively, render unconditionally and hide it until target exists (avoid insertion entirely).
msmps
Metadata
Metadata
Assignees
Labels
No labels