Skip to content

[lexical] Bug Fix: Prevent layout thrashing when setting element indent for no indent case#8111

Merged
InanBerkin merged 1 commit intomainfrom
fix-indent-layout-thrash
Feb 2, 2026
Merged

[lexical] Bug Fix: Prevent layout thrashing when setting element indent for no indent case#8111
InanBerkin merged 1 commit intomainfrom
fix-indent-layout-thrash

Conversation

@InanBerkin
Copy link
Copy Markdown
Contributor

@InanBerkin InanBerkin commented Feb 2, 2026

Description

When the editor is loaded, browser is forced to recalculate style because of getComputedStyle call in setElementIndent.

Previously, even when indent was 0, getComputedStyle was called but last style change was setting padding-inline-start to ''. With this change, I am avoiding calling getComputedStyle for the case where indent is 0 and returning early.

image

Layout thrash: https://web.dev/articles/avoid-large-complex-layouts-and-layout-thrashing

Closes #

Test plan

Before

See "Recalculate style" caused by setElementIndent in the profiler
Screenshot 2026-02-02 at 16 13 49

After

"Recalculate style" is still there but caused by another function (updateDOMSelection)
Screenshot 2026-02-02 at 16 13 13

Indentation works
https://github.com/user-attachments/assets/c41c07cc-2dfc-4337-8a8a-ca6689d089c7

Profiler results

indent_recalc.gz
without_indent_recalc.gz

@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 Feb 2, 2026
@vercel
Copy link
Copy Markdown

vercel bot commented Feb 2, 2026

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

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview, Comment Feb 2, 2026 5:33pm
lexical-playground Ready Ready Preview, Comment Feb 2, 2026 5:33pm

Request Review

@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Feb 2, 2026
@InanBerkin InanBerkin added this pull request to the merge queue Feb 2, 2026
Merged via the queue into main with commit ebc473e Feb 2, 2026
69 checks passed
rayterion pushed a commit to rayterion/lexical that referenced this pull request Feb 8, 2026
@etrepum etrepum mentioned this pull request Feb 25, 2026
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.

2 participants