fix: let the editor background cover overflowing content (#182) - #184
Merged
Conversation
When content is taller than a fixed-height editor container, the editor's background color stops at the fold and the container shows through below it. Two tests cover this: a geometry assertion that the .TinyMDE box is at least as tall as the scrollable content, and a pixel check that samples a screenshot below the fold after scrolling to the bottom. Both currently fail in chromium, firefox and webkit: the editor box is 310px against 965px of content, and the sampled pixel is the container color rather than the editor background. The fix follows. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GZM8Se4QqnhwfkAoRcdx4
.TinyMDE had height:100%, so in a fixed-height container the editor's box stayed at the container's height while its children overflowed. Since the background is painted by that box, everything scrolled past the fold showed the container through instead of the editor background. Use min-height:100% instead: the editor still fills the container when it's near-empty, but now grows with the content when it overflows, so the background covers the full scrollable area. For an auto-height container both forms resolve the same way, so unsized containers are unaffected. Makes the tests from the previous commit pass in chromium, firefox and webkit. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GZM8Se4QqnhwfkAoRcdx4
The test suite has run on Playwright, not Puppeteer, for a while, and npm run prepublishOnly no longer exists. Replace it with the scripts that do (typecheck, per-browser test runs, release/releasePatch), and note the three-browser project layout, the global test helpers, and that the test script builds to dist/ first. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GZM8Se4QqnhwfkAoRcdx4
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.
Fixes #182.
Problem
.TinyMDEhadheight: 100%(src/css/editor.css:8). In a fixed-height container — e.g. theheight:300px; overflow-y:scrollwrapper from the issue — the editor's box stayed at the container's height while its children overflowed it. The background is painted by that box, so everything scrolled past the fold showed the container through instead of the editor background.Fix
min-height: 100%instead. The editor still fills the container when it's near-empty, but now grows with the content when it overflows, so the background covers the full scrollable area. For an auto-height container both forms resolve the same way, so unsized containers are unaffected.Tests
Committed test-first, in
jest/editor-background.test.js— 344cd18 adds them failing, 8e27302 makes them pass. Two angles:.TinyMDEbox, so that box must be at least as tall ascontainer.scrollHeight.getImageData) rather than by adding an image library. The default Playwright context hasdeviceScaleFactor: 1, so screenshot and CSS pixels line up.Before the fix, in all three browsers:
Full suite green: 705 passed across chromium, firefox and webkit (699 before, +6 new).
Also in this PR
A
docs:commit correcting stale info inCLAUDE.md, noticed while writing the tests: it described the suite as Jest + Puppeteer (it's been Playwright for a while) and documented annpm run prepublishOnlyscript that no longer exists. Replaced with the scripts that do exist, plus the three-browser project layout and the global test helpers. Happy to split this out if you'd rather keep the PR to the fix.Not addressed
.TinyMDEhaspadding: 5pxwith defaultcontent-box, somin-height: 100%computes to container height plus 10px — a fixed-height container always has ~10px of spurious scroll (visible in the numbers above: 310 for a 300px container).box-sizing: border-boxwould fix it, but it shifts layout slightly for existing users and is a separate defect from #182, so I left it out.🤖 Generated with Claude Code
https://claude.ai/code/session_016GZM8Se4QqnhwfkAoRcdx4