mirror of
https://github.com/anomalyco/opentui.git
synced 2026-04-25 13:06:00 +03:00
[PR #200] [MERGED] Delegate scollbox insertBefore to content to fix “Anchor does not exist” error #366
Labels
No labels
bug
core
documentation
feature
good first issue
help wanted
pull-request
question
react
solid
tmux
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/opentui#366
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/anomalyco/opentui/pull/200
Author: @eli0shin
Created: 10/5/2025
Status: ✅ Merged
Merged: 10/5/2025
Merged by: @kommander
Base:
main← Head:scrollbox-insert-before-fix📝 Commits (1)
54473e2Delegate scollbox insertBefore to content to fix Anchor not found error📊 Changes
2 files changed (+46 additions, -1 deletions)
View changed files
📝
packages/core/src/renderables/ScrollBox.ts(+4 -0)📝
packages/core/src/tests/scrollbox.test.ts(+42 -1)📄 Description
Resolves https://github.com/sst/opentui/issues/199
The Bug
When inserting a React element in the middle of a list inside a
<scrollbox>, the application crashes with:Root Cause
ScrollBox has an internal wrapper structure where user content is added to a nested child (
this.content), not directly to the ScrollBox instance. The component hierarchy looks like:ScrollBox correctly overrides
add()andremove()to delegate tothis.content:add(obj, index)→this.content.add(obj, index)✓remove(id)→this.content.remove(id)✓However, ScrollBox was missing an override for
insertBefore().When React inserts an element in the middle of a list (e.g., when a conditional element appears after initial render), it calls:
Without the override, this uses the base
Renderable.insertBefore()which:anchorChildin the parent's direct children viarenderableMapByIdanchorChildis actually inthis.content(the wrapper), not in ScrollBox's direct childrenThe Fix
Added
insertBefore()override in ScrollBox to delegate tothis.content, matching the pattern used foradd()andremove():Impact Analysis
Affected Components
insertBefore()overrideinsertBefore()delegationAffected Renderers
insertBefore()directly)add(node, anchorIndex)pattern)add(node, anchorIndex)pattern)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.