[PR #645] [CLOSED] Add Renderable.scrollIntoView() #1466

Closed
opened 2026-03-14 09:38:11 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opentui/pull/645
Author: @cevr
Created: 2/7/2026
Status: Closed

Base: mainHead: feat/scroll-into-view


📝 Commits (1)

  • fb10b5b feat(core): add scrollChildIntoView and Renderable.scrollIntoView

📊 Changes

3 files changed (+156 additions, -0 deletions)

View changed files

📝 packages/core/src/Renderable.ts (+15 -0)
📝 packages/core/src/renderables/ScrollBox.ts (+18 -0)
packages/core/src/tests/scrollbox-scroll-into-view.test.ts (+123 -0)

📄 Description

Problem / Intent

There's no way to scroll a renderable into view from a ref. Consumers (e.g. Solid/React) need to call ref.scrollIntoView() to reveal a focused or selected item inside a ScrollBox — mirroring the DOM API.

Approach

Renderable.scrollIntoView() walks up the parent chain looking for a ScrollBox ancestor via duck typing ('scrollChildIntoView' in current), avoiding a circular dependency between Renderable and ScrollBox. The private ScrollBox.scrollChildIntoView(child) does the viewport math — scrolls the minimum amount to make the child fully visible, no-ops if already in view.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opentui/pull/645 **Author:** [@cevr](https://github.com/cevr) **Created:** 2/7/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/scroll-into-view` --- ### 📝 Commits (1) - [`fb10b5b`](https://github.com/anomalyco/opentui/commit/fb10b5bcf31fd76bdd1453acf8e30fc9b4fdb76e) feat(core): add scrollChildIntoView and Renderable.scrollIntoView ### 📊 Changes **3 files changed** (+156 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/core/src/Renderable.ts` (+15 -0) 📝 `packages/core/src/renderables/ScrollBox.ts` (+18 -0) ➕ `packages/core/src/tests/scrollbox-scroll-into-view.test.ts` (+123 -0) </details> ### 📄 Description ## Problem / Intent There's no way to scroll a renderable into view from a ref. Consumers (e.g. Solid/React) need to call `ref.scrollIntoView()` to reveal a focused or selected item inside a ScrollBox — mirroring the DOM API. ## Approach `Renderable.scrollIntoView()` walks up the parent chain looking for a ScrollBox ancestor via duck typing (`'scrollChildIntoView' in current`), avoiding a circular dependency between Renderable and ScrollBox. The private `ScrollBox.scrollChildIntoView(child)` does the viewport math — scrolls the minimum amount to make the child fully visible, no-ops if already in view. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-14 09:38:11 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentui#1466
No description provided.