Skip to content

Core: Tw::scroll_p*, Tailwind's scroll padding (fixes #439) - #441

Merged
samitbasu merged 2 commits into
mainfrom
scroll-pad
Nov 20, 2026
Merged

samitbasu merged 2 commits into
mainfrom
scroll-pad

Conversation

@samitbasu

Copy link
Copy Markdown
Owner

Fixes #439.

Tw::scroll_p*, Tailwind's scroll padding (scroll_p, scroll_px, scroll_py, scroll_pt, scroll_pr, scroll_pb, scroll_pl, in spacing units): scrolling a node into view keeps that much between it and the edges of the scroll container. It is honoured by every scroll-into-view: the keyboard highlight and focus (Wish::Node), scroll_to_rect, and a virtual list's scroll_to_row (which reveals against the same padded view). The wheel, touch and drag are unaffected, as in CSS. A scroll that reaches either end of the content still stops there, so the first row is flush with the top when the content starts there.

The class merges per side, the later non-zero value winning; a length that is not finite is ignored and noted, as the layout classes' are. TODO(prose) is on the method.

Tests (tests/it/scroll_padding.rs, through the real keys in a virtual list driven from a field): arrowing down keeps 4 pt (scroll_py(1.0)) between the highlighted row and the bottom edge; arrowing up from the last row never brings a highlighted row nearer the top than 4 pt, and a row scrolled to sits exactly 4 pt under the top edge (the first row, at the content's start, is flush); with no padding it sits flush; the wheel scrolls by exactly its delta.

The scroll, vlist, overflow and listbox tests (214) still pass, with clippy -D warnings and fmt.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AJYxo4YJZUXcPJ1bHdAHKy

samitbasu and others added 2 commits November 19, 2026 16:05
scroll_p, scroll_px, scroll_py, scroll_pt, scroll_pr, scroll_pb and
scroll_pl, in spacing units: scrolling a node into view keeps this much
between it and the edges of the scroll container. Every scroll-into-view
honours it: a keyboard highlight or focus (Wish::Node), scroll_to_rect, and a
virtual list's scroll_to_row, which reveals against the same padded view. The
wheel, touch and drag are unaffected, as in CSS. A scroll at either end of the
content still stops at the content's end.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AJYxo4YJZUXcPJ1bHdAHKy
Scroll padding and the scrollbar class sit side by side on Tw.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AJYxo4YJZUXcPJ1bHdAHKy
@samitbasu

Copy link
Copy Markdown
Owner Author

Approved by the user after the combobox trial (2026-11-19). GitHub's required checks pass on the branch merged with current main. Merging.

@samitbasu
samitbasu merged commit e984119 into main Nov 20, 2026
4 checks passed
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.

Core: scroll padding (Tailwind's scroll-p*), honoured by scroll-into-view

1 participant