Stop inline backgroundColor from hiding the selection layer#181
Conversation
The translucent local-selection, search, and peer-cursor highlights were drawn before each run's text, but `renderRun` then painted the opaque `style.backgroundColor` fillRect on top of them — so the blue selection band became invisible inside any colored span. Tables had already split cell backgrounds into a pre-pass to avoid the same issue; this commit extends that pattern to inline run backgrounds. `DocCanvas.drawInlineRunBackgrounds` walks the body's PageLines once right after the table-cell-background pass and paints every run's `style.backgroundColor`. `renderRun` gets a `skipBackground` flag so the body path doesn't double-paint; header/footer paths keep `skipBackground=false` since they don't share the body's two-pass pipeline. Inside tables, `renderTableBackgrounds` now also walks each cell's lines × runs for inline backgrounds, sharing the verticalAlign / merged-cell line-Y math with `renderTableContent` through a new `computeCellLineAbsoluteYs` helper. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR fixes a rendering bug where inline text-run background colors obscure selection and highlight layers. The solution adds a dedicated pre-pass that paints inline run backgrounds before highlights, skips redundant background painting in the content pass, and refactors table rendering to compute per-line absolute Y coordinates and paint inline backgrounds during the background pre-pass instead of content rendering. ChangesBackground Rendering Reordering
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 55 minutes and 11 seconds.Comment |
The fix shipped in this branch (#181). Move the todo from active to the May 2026 archive bucket and refresh the task index READMEs. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Verification: verify:selfResult: ✅ PASS in 133.2s
Verification: verify:integrationResult: ✅ PASS |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Summary
When a text run carries
style.backgroundColor(Word/Docs-style"highlight"), the local selection, search match, and peer-cursor
highlights were all but invisible inside the colored span. Root cause
was the render order in
DocCanvas.render: the translucent highlightlayers were drawn first, then
renderRunpainted the opaque inlinebackgroundColorfillRect on top of them.Tables had already solved the analogous issue for cell backgrounds by
splitting into
renderTableBackgrounds(pre-selection) andrenderTableContent(post-selection). This PR extends that pattern toinline run backgrounds.
DocCanvas.drawInlineRunBackgroundswalks the body's PageLines onceright after the table-cell-background pass and paints every run's
style.backgroundColor.renderRungets askipBackgroundflag sothe body path doesn't double-paint.
renderTableBackgroundsnow also walks each cell's lines × runs forinline backgrounds. A new
computeCellLineAbsoluteYshelper sharesthe verticalAlign / merged-cell line-Y math with
renderTableContent, which now skips the inline bg fill.skipBackground=falseand continue to drawbg inside
renderRun— they don't share the body's two-pass pipelineyet (noted as follow-up in the task todo).
Test plan
pnpm verify:fast(44 docs files / 739 tests passed)packages/docs/test/view/table-renderer.test.ts:-
renderTableBackgroundspaints inline run bg in thebackground pass
-
renderTableContentno longer paints inline run bgdrag-select across it, confirm the blue selection band is
visible over the yellow
🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
Bug Fixes
Tests
Documentation