mirror of
https://github.com/anomalyco/opentui.git
synced 2026-04-24 20:45:56 +03:00
[PR #753] feat: add allowUserScroll option to disable user-initiated scrolling #1539
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#1539
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/753
Author: @kassieclaire
Created: 2/28/2026
Status: 🔄 Open
Base:
main← Head:feature/allow-user-scroll📝 Commits (10+)
ff1eb98add allowUserScroll option to disable user-initiated scrolling on ScrollBox344f992fix: guard slider's mouse handlers when user-initiated scrolling is disabled81e077dfeat(quick-001): add allowUserInput property to Sliderf8bd371feat(quick-001): propagate allowUserInput from ScrollBar to Sliderd64bed3fix(quick-001): fix Box focusable option to use setterbf81188test(quick-001): add unit tests for allowUserScroll blocking all input methods270fafefeat(quick-002): add slider thumb drag demonstration to demo12a4f7cfeat(quick-002): update tape file timing and regenerate GIF1b06516fix(003): isDragging always resets on mouseup regardless of allowUserInput8f1357ftest(003): add test for isDragging reset when allowUserInput disabled📊 Changes
10 files changed (+747 additions, -5 deletions)
View changed files
➕
demos/allow-user-scroll-demo.gif(+0 -0)➕
packages/core/src/examples/allow-user-scroll-demo.ts(+458 -0)📝
packages/core/src/examples/index.ts(+7 -0)📝
packages/core/src/renderables/Box.ts(+2 -2)📝
packages/core/src/renderables/ScrollBar.ts(+26 -0)📝
packages/core/src/renderables/ScrollBox.ts(+27 -1)📝
packages/core/src/renderables/Slider.test.ts(+29 -0)📝
packages/core/src/renderables/Slider.ts(+15 -2)📝
packages/core/src/tests/scrollbox.test.ts(+141 -0)➕
scripts/demo-allow-user-scroll.tape(+42 -0)📄 Description
feat: add allowUserScroll option to disable user-initiated scrolling
Summary
Adds a new
allowUserScrollboolean option toScrollBoxRenderablethat optionally disables user-initiated scrolling (mouse wheel, keyboard, scrollbar arrows) while still allowing programmatic/auto-scrolling. This is useful for log viewers, chat interfaces, or any scrollable view that should remain sticky to the bottom while receiving new content.Changes
Core Implementation
packages/core/src/renderables/ScrollBox.ts
allowUserScroll?: booleanoption toScrollBoxOptions(defaults totrue)_allowUserScrollfield with getter/setteronMouseEvent()to skip scroll events whenallowUserScrollisfalsehandleKeyPress()to returnfalseimmediately whenallowUserScrollisfalseupdateScrollBarUserScroll()method to propagate setting to scrollbarspackages/core/src/renderables/ScrollBar.ts
allowUserInput?: booleanproperty (defaults totrue)handleKeyPress()to respectallowUserInputflagonMouseDownhandlers to checkallowUserInputbefore scrollingisDraggingnow always resets on mouseup regardless ofallowUserInputstatepackages/core/src/renderables/Slider.ts
allowUserInput?: booleanproperty (defaults totrue)allowUserInputis disabled mid-dragpackages/core/src/renderables/Box.ts
focusableoption now properly uses setter to ensure focus manager registrationDemo & Documentation
packages/core/src/examples/allow-user-scroll-demo.ts (new)
allowUserScroll = true(user scrolling enabled)allowUserScroll = false(user scrolling disabled, auto-scroll only)packages/core/src/examples/index.ts
scripts/demo-allow-user-scroll.tape (new)
Demo
Demo: Side-by-side comparison showing left panel (
allowUserScroll = true) responding to scroll input while right panel (allowUserScroll = false) remains fixed at the bottom, only auto-scrolling when new content is added.The demo shows:
Usage
Testing
bun run src/examples/allow-user-scroll-demo.tsscrollTop,scrollBy) still worksallowUserScroll = falseallowUserScrollblocking all input methodsisDraggingreset behavior whenallowUserInputis disabled mid-dragRelated
Resolves: N/A (new feature)
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.