Skip to content

sticky elements scroll away with content #803

Description

@XDLCS

Steps to reproduce

<!DOCTYPE html>
<html>
<head><style>
  body { margin: 0; height: 2000px; }
  #sticky { position: sticky; top: 10px; width: 100px; height: 40px; background: green; }
</style></head>
<body>
  <div id="sticky"></div>
</body>
</html>

Scroll with window.scrollTo(0, 50), then read document.getElementById('sticky').getBoundingClientRect().top.

Expected (Chrome 154)

The sticky element clamps to its inset: top = 10.

Actual (moli 1.1.10, 9b2f86b)

The element scrolls away with the content: top = -40.

getComputedStyle().position is "sticky" and initial placement is correct — only the re-clamping on scroll offset change is missing (finish_sticky_positioning runs only during layout in taffy_tree.rs). The same defect applies to horizontal flex containers (left inset not clamped).

Suggestion

Re-run inset clamping for sticky boxes when the scroll offset changes.

Environment

  • moli 1.1.10 (9b2f86b), Linux
  • CDP probe vs Chrome 154.0.8037.57, same fixture and probe

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions