Skip to content

feat(native): paint scrollbars and scroll an element into view - #4

Closed
mateo-m wants to merge 16 commits into
feat/layer-effectsfrom
feat/scrollbars
Closed

mateo-m wants to merge 16 commits into
feat/layer-effectsfrom
feat/scrollbars

Conversation

@mateo-m

@mateo-m mateo-m commented Aug 26, 2026

Copy link
Copy Markdown
Owner

Contains #3.

What this adds

A box with overflow: scroll or auto gets a scrollbar on each axis it scrolls. The OS picks overlay or classic, as a browser does. An overlay bar shows for a second after a scroll and fades. A classic bar sits in a gutter the layout reserves. A drag of the thumb scrolls, a click in the track moves one page. scrollbar-width, scrollbar-color and scrollbar-gutter (with stable both-edges) work. scrollbar-color takes auto or exactly two colours, as css defines it, and one colour drops the declaration. GPUIX_SCROLLBARS=overlay|classic overrides the OS choice for tests. A bar paints after the whole frame, above sibling effects. scrollIntoView(elementId, block, inline) scrolls every scroll box around an element, with scroll-margin and scroll-padding honoured, and the TestRenderer wraps it for the react tests.

What I ran and saw

  • cargo test at this branch: 301 passed, 0 failed. Unit tests cover the two-colour rule and the overscroll shorthand split.
  • The react suite at this branch: 431 passed, 0 failed, and the scrollbars suite calls scrollIntoView through the TestRenderer.
  • The generated index.d.ts comes from bun run build at this commit, not from a hand edit.

What I did not verify

  • Windows and Linux scrollbar picks. The OS probe ran on macOS only. CI builds the other targets.

Copilot AI 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.

🟡 Changes recommended

The new scrollIntoView tests call root.renderer.scrollIntoView(...), but the JS TestRenderer wrapper does not implement that method, which will fail at runtime unless the wrapper is updated.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR extends GPUIX’s native rendering pipeline to support browser-like scrolling affordances: it paints scrollbars for scroll boxes (overflow: scroll|auto) and adds a scrollIntoView(elementId, block, inline) API that scrolls ancestor scroll containers while honoring scroll-margin and scroll-padding.

Changes:

  • Add native scrollbar rendering (overlay/classic modes) with support for scrollbar-width, scrollbar-color, and scrollbar-gutter.
  • Implement scrollIntoView end-to-end (native renderer + test renderer), including scroll-margin/scroll-padding resolution.
  • Add React-side type updates and a dedicated scrollbar/scrollIntoView native test suite, plus a changeset.
File summaries
File Description
packages/react/src/types/host.ts Extends StyleDesc and NativeRenderer typings for scrolling + scrollIntoView.
packages/react/src/tests/scrollbars.test.tsx Adds native tests covering classic/overlay scrollbars and scrollIntoView behavior.
packages/native/src/test_renderer.rs Exposes scrollIntoView in the native test renderer; refactors scroll offset conversion.
packages/native/src/style/resolve.rs Updates overflow resolution to treat clip like hidden and apply used-overflow coercion.
packages/native/src/style.rs Adds style fields for scrollbar and scroll-into-view related properties.
packages/native/src/renderer/scrollbar.rs New native scrollbar implementation (rendering + input handling + CSS-like parsing).
packages/native/src/renderer/scroll_into_view.rs New scroll-into-view implementation honoring margins/padding and alignment modes.
packages/native/src/renderer/frame.rs Integrates scrollbars into div build, including gutter reservation and element insertion.
packages/native/src/renderer.rs Wires scrollIntoView through NAPI and UI command routing; adds offset_to_js.
packages/native/index.d.ts Regenerated declarations reflecting the new scrollIntoView API.
.changeset/scrollbars.md Changeset documenting scrollbar rendering and scrollIntoView additions.
Review details
  • Files reviewed: 10/11 changed files
  • Comments generated: 4
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/react/src/__tests__/scrollbars.test.tsx
Comment thread packages/native/src/renderer/scrollbar.rs
Comment thread packages/react/src/types/host.ts Outdated
Comment thread packages/react/src/types/host.ts Outdated
@mateo-m

mateo-m commented Sep 4, 2026

Copy link
Copy Markdown
Owner Author

Moved to remorses#53.

@mateo-m mateo-m closed this Sep 4, 2026
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.

2 participants