Skip to content

fix: let the editor background cover overflowing content (#182) - #184

Merged
jefago merged 3 commits into
mainfrom
fix/editor-background-scroll-height
Aug 1, 2026
Merged

fix: let the editor background cover overflowing content (#182)#184
jefago merged 3 commits into
mainfrom
fix/editor-background-scroll-height

Conversation

@jefago

@jefago jefago commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Fixes #182.

Problem

.TinyMDE had height: 100% (src/css/editor.css:8). In a fixed-height container — e.g. the height:300px; overflow-y:scroll wrapper 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.js344cd18 adds them failing, 8e27302 makes them pass. Two angles:

  • Geometry: the background is painted by the .TinyMDE box, so that box must be at least as tall as container.scrollHeight.
  • Pixel: sets the container background to red, fills past the fold, scrolls to the bottom, screenshots, and samples one pixel below the fold — which is the symptom as reported. The PNG is decoded in the browser already open (data URL → canvas → getImageData) rather than by adding an image library. The default Playwright context has deviceScaleFactor: 1, so screenshot and CSS pixels line up.

Before the fix, in all three browsers:

expect(received).toBeGreaterThanOrEqual(expected)
Expected: >= 965      Received: 310

Array [ 255, -255, -255 ]   <- expected white
       [ 255, +0,   +0   ]   <- got the container red

Full suite green: 705 passed across chromium, firefox and webkit (699 before, +6 new).

Also in this PR

A docs: commit correcting stale info in CLAUDE.md, noticed while writing the tests: it described the suite as Jest + Puppeteer (it's been Playwright for a while) and documented an npm run prepublishOnly script 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

.TinyMDE has padding: 5px with default content-box, so min-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-box would 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

jefago and others added 3 commits August 1, 2026 04:44
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
@jefago
jefago marked this pull request as ready for review August 1, 2026 03:53
@jefago
jefago merged commit 87a67d7 into main Aug 1, 2026
2 checks passed
@jefago
jefago deleted the fix/editor-background-scroll-height branch August 1, 2026 03:53
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.

Writing over the height of the editor loses the background color

1 participant