Repository navigation
Keep a code block as tall when its line scrolls as when it fits - #258
Merged
Merged
Conversation
The code's bottom padding gave up the scrollbar token's 0.375rem whenever its line scrolled, whether or not the scrollbar took that room. Where it lies over the code, as on a phone or in a headless browser, a block whose line scrolled was 6 px shorter. The block now measures the room its sideways scrollbar takes, on each border-box resize of its body, and its bottom padding gives up exactly that. Issue #18 Agent: DEV1 (developer) Agent-Model: Anthropic Opus 5.5, Medium
rostislavrotaru
commented
Nov 30, 2026
Until the block measures its sideways scrollbar, the padding gives up the scrollbar token while the line scrolls under a fine pointer, so prerendered pages and the first frame match the measured height. Agent: DEV1 (developer) Agent-Model: Anthropic Opus 5.5, Medium
The site code block shares the code block's behavior and stylesheet, but its host did not set the measured scrollbar height, so its padding kept the unmeasured guess. Agent: DEV1 (developer) Agent-Model: Anthropic Opus 5.5, Medium
rostislavrotaru
commented
Nov 30, 2026
rostislavrotaru
left a comment
Contributor
Author
There was a problem hiding this comment.
Reviewed: #258 at 7f43022
Verdict: Approve
Findings: 0 Should fix, 0 Low, as line comments
Why it's right: the padding gives up only the scrollbar the block measures, with the token as its guess under a fine pointer until then, so a code block keeps one height whether its line fits or scrolls; the site code block now binds the same measured value, and the specs check both before and after the measure.
Agent: LEAD (lead)
Agent-Model: Anthropic Opus 5.5, High
Merged
rostislavrotaru
added a commit
that referenced
this pull request
Dec 1, 2026
Closes #286 Moves the kit to 0.0.48, with what has merged since 0.0.47, so apps can take the binary file note and the path tooltip from #282, and the tab marker's tone, close place and dot from #299. ## What changes - `version.json` is at 0.0.48. - `CHANGELOG.md` has the 0.0.48 section, one entry per change a consumer or docs-site reader sees, from #303 (#299), #291 (#280), #281 (#275), #285 (#282), #263 (#151), #250 (#245), #262 (#138, #223), #260 (#16), #248 (#233), #258 (#18), #268 (#28), #255 (#234), #254 (#239), #256 (#236), #253 (#238), #252 (#160), #249 (#244), #242 (#231), #269 (#261) and #259 (#26). - Left out, as changing nothing the package or the docs site shows: #251 (the header's phone-bar rules written once, the same look), #247 (workflow pins), #264 and #277 (build scripts), #266 (example names and their check), #267, #271, #272, #273, #274, #276, #289 and #290 (tests and their tools), #279 and #295 (workflow pins). ## Checks No test covers these two files. The product names check reads the new section in CI; it names no product. Agent: DEV2 (developer) Agent-Model: Anthropic Opus 5.5, Medium
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #18
The cause
When its line scrolled sideways, the code's bottom padding gave up the scrollbar token, 0.375rem. It did this through a
scroll-state(scrollable: inline)container query, which assumes the scrollbar always takes that room.A scrollbar that lies over the code, as on a phone or in a headless browser, takes none. So a block whose line scrolled was 6 px shorter than one whose line fit.
Measured in the test browser on Linux, macOS and Windows, a one-line block 335 px wide:
The fix
The block now measures the room its sideways scrollbar takes, as its body's
offsetHeight − clientHeight. It sets that as--nol-code-scrollbar-height, and the code's bottom padding gives up exactly that:The block measures again on every border-box resize of its body, through the ResizeObserver it already has. A scrollbar that takes room grows that box when the line starts to scroll and shrinks it when the line stops.
Until the block has measured, as in prerendered HTML or the first frame of a client render, the padding gives up a likely bar instead:
scroll-state(scrollable: inline)query main used), the likely bar is the kit's--nol-scrollbar-size. Mouse desktops, whose Chromium and Safari draw the kit's classic bar, are right from first paint.Firefox and forced colors draw system bars of other sizes; there the measurement corrects the height once it runs.
Changes, by path
src/noldova.ui.components.angular/src/app/components/code-block/code-block-behavior.ts:scrollbarHeight, measured bymeasureScrollbarin the existing layout observer, which now also watches the body's border box.src/noldova.ui.components.angular/src/app/components/code-block/code-block.component.tsandsite-code-block.component.ts: the host sets--nol-code-scrollbar-heightfrom it.src/noldova.ui.components.angular/src/app/components/code-block/code-block.component.css:--nol-code-scrollbar-height, or before it is measured,--nol-code-scrollbar-guess.scroll-statequery now sets that guess to the scrollbar token under(pointer: fine), in place of setting the padding.src/noldova.ui.components.angular/tests/app/components/code-block/code-block-scroll-height.component.spec.ts, new:src/noldova.ui.components.angular/tests/app/components/code-block/site-code-block.component.spec.ts: the site block and the code block are compared once both have measured their scrollbar.src/noldova.ui.components.angular/tests/app/components/code-block/code-block-scrollbar.component.spec.ts: the bottom padding is 0.875rem minus the room the scrollbar takes, measured, in place of minus the token.src/noldova.ui.components.angular/tests/app/components/code-block/code-block-code-size.component.spec.tsandcode-block-code-size-dark.component.spec.ts:Not covered by a test
The measurement of a classic scrollbar, one that takes room, has no test. The specs run in headless Chromium, which hides scrollbars: even with a styled
::-webkit-scrollbarheight, no scrollbar takes room there. The classic-bar spec checks the padding and height arithmetic from a measured value. The measurement itself is checked where the bar takes 0 px.Checks
Agent: DEV1 (developer)
Agent-Model: Anthropic Opus 5.5, Medium