Skip to content

Fix occluded-content height inflation from inherited line-height#491

Merged
runspired merged 1 commit intohtml-next:mainfrom
johanrd:fix-unstable-occluded-content-height
Jan 24, 2026
Merged

Fix occluded-content height inflation from inherited line-height#491
runspired merged 1 commit intohtml-next:mainfrom
johanrd:fix-unstable-occluded-content-height

Conversation

@johanrd
Copy link
Contributor

@johanrd johanrd commented Nov 28, 2025

Summary

Fixes an issue where occluded-content height could be inflated by inherited line-height when used inside tables, causing visual jumps during scrolling.

Problem

When using VerticalCollection inside a <table>:

  • The occluded-content element renders as display: table-row
  • It contains debug text like "And 5 items before"
  • If the page has a line-height set (e.g., from Tailwind or global styles), this text creates a line box
  • The actual rendered height (getBoundingClientRect().height) becomes larger than the inline style="height: 44px"
  • VerticalCollection measures this inflated height and "corrects" its estimate upward
  • This causes rows to visually jump (e.g., 44px → 96.5px) when they first appear
Screenshot 2025-11-28 at 14 16 06

Solution

Add font-size: 0 and line-height: 0 to .occluded-content CSS, ensuring the debug text cannot affect layout height.

Test plan

  • Added test verifying line-height: 0 is set on occluded-content
  • Added test verifying actual height matches style height in tables
  • Verified test fails without fix, passes with fix

Before fix:
not ok 1 - occluded-content should have line-height: 0
expected: 0px
actual: 20px

After fix:
ok 1 - occluded-content should have line-height: 0

@NullVoxPopuli
Copy link
Contributor

@johanrd would you be willing to rebase this PR since the repo is now a v2 addon? <3

  When occluded-content is rendered inside a table (display: table-row),
  the debug text ("And X items before/after") can create a line box that
  inflates the element's actual height above its inline style height.
  This causes VerticalCollection to measure the wrong height and adjust
  its estimates, leading to visual jumps when scrolling.

  Add font-size: 0 and line-height: 0 to prevent the text from affecting
  layout while keeping it available for screen readers.
@johanrd johanrd force-pushed the fix-unstable-occluded-content-height branch from 360957f to dcde090 Compare January 23, 2026 23:42
@johanrd
Copy link
Contributor Author

johanrd commented Jan 23, 2026

@NullVoxPopuli thanks! done👍

@runspired runspired merged commit 2e08541 into html-next:main Jan 24, 2026
11 checks passed
@github-actions github-actions bot mentioned this pull request Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants