summaryrefslogtreecommitdiffhomepage
path: root/packages/ui/src
diff options
context:
space:
mode:
authoradamelmore <[email protected]>2026-01-24 15:00:10 -0600
committeradamelmore <[email protected]>2026-01-24 15:01:17 -0600
commit847a7ca00971f505464d9df65d692920babf67fe (patch)
tree2aeae5f18bfcc76ac2a703142332e5e8407a33d4 /packages/ui/src
parentdc1ff0e63e78aa998074678d7fbdfeee5ab8adab (diff)
downloadopencode-847a7ca00971f505464d9df65d692920babf67fe.tar.gz
opencode-847a7ca00971f505464d9df65d692920babf67fe.zip
fix(app): don't show scroll to bottom if no scroll
Diffstat (limited to 'packages/ui/src')
-rw-r--r--packages/ui/src/hooks/create-auto-scroll.tsx22
1 files changed, 21 insertions, 1 deletions
diff --git a/packages/ui/src/hooks/create-auto-scroll.tsx b/packages/ui/src/hooks/create-auto-scroll.tsx
index c8c380cb8..c32017739 100644
--- a/packages/ui/src/hooks/create-auto-scroll.tsx
+++ b/packages/ui/src/hooks/create-auto-scroll.tsx
@@ -30,6 +30,10 @@ export function createAutoScroll(options: AutoScrollOptions) {
return el.scrollHeight - el.clientHeight - el.scrollTop
}
+ const canScroll = (el: HTMLElement) => {
+ return el.scrollHeight - el.clientHeight > 1
+ }
+
// Browsers can dispatch scroll events asynchronously. If new content arrives
// between us calling `scrollTo()` and the subsequent `scroll` event firing,
// the handler can see a non-zero `distanceFromBottom` and incorrectly assume
@@ -89,6 +93,12 @@ export function createAutoScroll(options: AutoScrollOptions) {
}
const stop = () => {
+ const el = scroll
+ if (!el) return
+ if (!canScroll(el)) {
+ if (store.userScrolled) setStore("userScrolled", false)
+ return
+ }
if (store.userScrolled) return
setStore("userScrolled", true)
@@ -111,6 +121,11 @@ export function createAutoScroll(options: AutoScrollOptions) {
const el = scroll
if (!el) return
+ if (!canScroll(el)) {
+ if (store.userScrolled) setStore("userScrolled", false)
+ return
+ }
+
if (distanceFromBottom(el) < threshold()) {
if (store.userScrolled) setStore("userScrolled", false)
return
@@ -149,6 +164,11 @@ export function createAutoScroll(options: AutoScrollOptions) {
createResizeObserver(
() => store.contentRef,
() => {
+ const el = scroll
+ if (el && !canScroll(el)) {
+ if (store.userScrolled) setStore("userScrolled", false)
+ return
+ }
if (!active()) return
if (store.userScrolled) return
// ResizeObserver fires after layout, before paint.
@@ -159,7 +179,7 @@ export function createAutoScroll(options: AutoScrollOptions) {
)
createEffect(
- on(options.working, (working) => {
+ on(options.working, (working: boolean) => {
settling = false
if (settleTimer) clearTimeout(settleTimer)
settleTimer = undefined