Skip to content

fix(nsgotest): pull an offset past a scroll view's end back to it, as macOS does - #1028

Open
iFwu wants to merge 1 commit into
nsgo-dev:mainfrom
iFwu:fix/nsgotest-clamp-shrunk-scroll
Open

iFwu wants to merge 1 commit into
nsgo-dev:mainfrom
iFwu:fix/nsgotest-clamp-shrunk-scroll

Conversation

@iFwu

@iFwu iFwu commented Nov 20, 2026

Copy link
Copy Markdown

Summary

Fixes #1020.

apply took a scroll view's new content size (ItemScrollContent) and frame (ItemFrame), but it left the offset where it was, past the new end, and the app heard no scroll report. macOS pulls the offset back to the end once the scroll is at rest and reports where it went (internal/platform/macos/scroll.go:591-592, :799-809). nsgotest now does the same once the rest of the batch is applied, including the ItemScrollBy that keeps the visible content in place: it pulls each resized scroll view that does not zoom back to its end and posts the EventScroll. A test of an app that reacts to that report now sees the offset the app ends up with on a Mac.

  • nsgotest/model.go: apply remembers the scroll views whose content or frame changed, and after the batch pulls an offset past the end back to it.
  • nsgotest/mount_test.go: TestScrollPastItsEndComesBackToIt shrinks the content under a scroll at its end, then grows the viewport past it. It fails on main with content shrank: offset 400, the app heard 400, want the new end 200 and viewport grew: offset 400, the app heard 400, want the new end 150.
  • CHANGELOG.md: an Unreleased line.

I only checked the macOS backend. The iOS driver only sets the UIScrollView's contentSize (internal/platform/ios/behavior.go:310-317), and UIKit leaves contentOffset where it is. If headless should follow the target OS here, I can limit the pull-back to the desktop environments.

Targets

  • Shared code (core, base, ui, tsx, the nsgo tool)
  • macOS
  • iOS
  • tvOS
  • watchOS
  • Android
  • Windows
  • Linux
  • Web
  • Mini programs
  • Docs or website only

Screenshots

None.

Verification

  • go tool nsgo test -run '^TestScrollPastItsEndComesBackToIt$' ./nsgotest fails on main at 4b3a9f7c and passes with this change, three runs out of three.
  • go tool nsgo check on Linux x86_64 (the host): passes.
  • go tool nsgo test on Linux x86_64 under Xvfb (GDK_BACKEND=x11, GSK_RENDERER=cairo, a private D-Bus session and a temporary HOME): 3,075 passed, 8 failed, 59 skipped. Main at 4b3a9f7c in the same environment: 3,074 passed, with the same 8 failing.
    • TestAccessibilitySelectedAndExpandedReachATSPI: no AT-SPI registry.
    • TestVideoShowsWhatIsBehindItsTransparentPixels: no GStreamer plug-in for the alpha video.
    • Six TestInstance*: the run's long TMPDIR pushed their socket paths past the address limit. All six pass three times out of three with a short one.
  • Not run: -target tests, as the change is in the headless model only.

Checklist

  • The title is a Conventional Commit, such as fix(linux): keep the caret after a paste; a squash merge uses it as the commit subject.
  • Docs whose facts change are updated, and CHANGELOG.md's Unreleased has a line for a capability users can see.
  • New third-party code, assets and dependencies name their source and license.

… macOS does

apply took a scroll view's new content size and frame but left its offset where it was, past the new end, where macOS pulls it back to the end once the scroll is at rest and reports where it went. Once the rest of the batch is applied, the ItemScrollBy keeping the visible content in place included, apply now pulls each resized scroll view that does not zoom back to its end and posts the scroll report.

Fixes nsgo-dev#1020
@github-actions github-actions Bot added size/S bug Something isn't working documentation Improvements or additions to documentation labels Nov 20, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nsgotest: a scroll view's offset stays past the end after its content shrinks or its viewport grows, where macOS pulls it back

1 participant