Skip to content

[lexical] Bug Fix: respect CSS scroll-padding in scrollIntoViewIfNeeded - #8218

Merged
etrepum merged 3 commits into
meta:mainfrom
takenosuke-code:fix/scroll-padding-not-respected
Mar 13, 2026
Merged

etrepum merged 3 commits into
meta:mainfrom
takenosuke-code:fix/scroll-padding-not-respected

Conversation

@takenosuke-code

Copy link
Copy Markdown
Contributor

Summary

  • Fixes scrollIntoViewIfNeeded to respect CSS scroll-padding-top and scroll-padding-bottom on the document element
  • When scrolling the cursor into view, the function now accounts for sticky headers/footers that use scroll-padding

Closes #6016

Test Plan

  • Added unit test verifying scroll amount differs by exactly the scroll-padding value
  • pnpm run test-unit packages/lexical/src/__tests__/unit/LexicalUtils.test.ts passes

@vercel

vercel Bot commented Mar 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview, Comment Mar 13, 2026 1:23am
lexical-playground Ready Ready Preview, Comment Mar 13, 2026 1:23am

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 12, 2026
const rootElement = editor.getRootElement()!;
const doc = rootElement.ownerDocument;

// Mock scrollBy to capture scroll amounts

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be cleaner to use vi.spyOn instead of manually applying and resetting the mock

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the feedback ! I implemented your suggestion.

@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Mar 13, 2026
@etrepum etrepum changed the title fix(lexical): respect CSS scroll-padding in scrollIntoViewIfNeeded [lexical] Bug Fix: respect CSS scroll-padding in scrollIntoViewIfNeeded Mar 13, 2026
@etrepum
etrepum added this pull request to the merge queue Mar 13, 2026
Merged via the queue into meta:main with commit 3c3a3a6 Mar 13, 2026
38 checks passed
levensta pushed a commit to levensta/lexical that referenced this pull request Mar 13, 2026
@etrepum etrepum mentioned this pull request Mar 19, 2026

This branch was successfully deployed

2 active deployments
Preview – lexical-playground — c0e5e8f0 Deployed Mar 13, 2026 by vercel[bot]
Preview – lexical — c0e5e8f0 Deployed Mar 13, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: CSS property scroll-padding not working

2 participants