Skip to content

fix(renderer): make ScrollBox defaults sane#79

Merged
re-marked merged 2 commits into
mainfrom
codex/fix-scrollbox-defaults-clamping
May 7, 2026
Merged

fix(renderer): make ScrollBox defaults sane#79
re-marked merged 2 commits into
mainfrom
codex/fix-scrollbox-defaults-clamping

Conversation

@re-marked

Copy link
Copy Markdown
Owner

Summary

  • Default <ScrollBox> layout to flexDirection: 'column' so normal vertical lists/logs produce scrollable content without a workaround.
  • Clamp scrollTo and scrollBy targets to [0, scrollHeight - viewportHeight] while preserving the existing pending-delta drain path for smooth wheel scrolling.
  • Add ScrollBox regression tests and update ScrollBox docs/changelog notes.

Closes #54.
Closes #74.

Verification

  • pnpm test -- packages/renderer/src/components/ScrollBox.test.tsx
  • pnpm --filter @yokai-tui/renderer typecheck
  • pnpm --filter @yokai-tui/renderer lint
  • pnpm --filter @yokai-tui/renderer build
  • git diff --check

Co-Authored-By: Mark <psyhik17@gmail.com>

Co-Authored-By: Codex <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1499af4e83

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

export function clampScrollTop(el: DOMElement, y: number): number {
const target = Math.floor(y)
if (!Number.isFinite(target)) return 0
return Math.max(0, Math.min(getScrollMax(el), target))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve requested scrolls until fresh layout bounds exist

When this runs before the first renderer pass or immediately after children grow, scrollHeight and scrollViewportHeight are still unset or stale because the renderer refreshes them later in render-node-to-output. Clamping here makes mount-time scrollTo(10) collapse to 0 and can truncate scrollBy during the same commit to the old max, so the later render no longer has the caller's requested target to clamp against fresh Yoga bounds; before this change the requested offset/delta survived until render-time clamping.

Useful? React with 👍 / 👎.

Co-Authored-By: Mark <psyhik17@gmail.com>

Co-Authored-By: Codex <noreply@anthropic.com>
@re-marked
re-marked merged commit ca4767a into main May 7, 2026
1 check passed
@re-marked
re-marked deleted the codex/fix-scrollbox-defaults-clamping branch May 7, 2026 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A19: <ScrollBox> scrollBy / scrollTo don't auto-clamp to content bounds A2: <ScrollBox> defaults flexDirection: 'row'

1 participant