Question: Is scroll indicator position calculation based on selectedIndex intentional or a bug?
Description I noticed that the scroll indicator in SelectRenderable calculates its position based on selectedIndex instead of scrollOffset. I'm uncertain whether this is intentional design or a bug, so I'd like to clarify before submitting a fix. Current Implementation In packages/core/src/renderables/Select.ts (line 235): private renderScrollIndicatorToFrameBuffer( contentX: number, contentY: number, contentWidth: number, contentHeight: number, ): void { if (!this.frameBuffer) return const scrollPercent = this._selectedIndex / Math.max(1, this._options.length - 1) const indicatorHeight = Math.max(1, contentHeight - 2) const indicatorY = contentY + 1 + Math.floor(scrollPercent * indicatorHeight) const indicatorX = contentX + contentWidth - 1 this.frameBuffer.drawText("█", indicatorX, indicatorY, parseColor("#666666")) } My Concern The scroll indicator position is calculated using selectedIndex (the index of the currently selected item), not scrollOffset (the actual scroll position in the viewport). This leads to behavior that seems counterintuitive to me:
- Indicator moves with selection, not scroll: When navigating through items, the indicator position reflects which item is selected, not where the viewport is positioned in the list.
- Misleading visual feedback: In a list with many items (e.g., 50 items), if I select item 25, the indicator jumps to the middle of the scrollbar area, even if the viewport hasn't actually scrolled to the middle yet.
- Inconsistent with typical scrollbar behavior: In most UI frameworks, scroll indicators represent the viewport's position relative to the total content, not the cursor/selection position. Expected Behavior (if this is a bug) If this is indeed a bug, I would expect the calculation to be: const maxScrollOffset = Math.max(1, this._options.length - this.maxVisibleItems) const scrollPercent = this.scrollOffset / maxScrollOffset This would make the indicator show the actual scroll position of the viewport. Question Is the current behavior intentional? If so, could you explain the design rationale? If it's a bug, I'd be happy to submit a PR to fix it. Context
- @opentui/core version: 0.2.6
- I encountered this while using the Select component with showScrollIndicator: true and a large number of options.