Repository navigation
[lexical-list] Bug Fix: remove the stale depth theme class when a list changes depth - #9077
Merged
Merged
Conversation
…t changes depth $setListThemeClassNames built the class names to remove by concatenating the tag with the index (ul0, ul1, ...) instead of reading them out of the theme's ulDepth/olDepth array. Those strings are never on the element, so the removal did nothing and a list whose DOM element is reused across a depth change kept both depth classes.
nithin42
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
August 19, 2026 17:34
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
approved these changes
Aug 20, 2026
Merged
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
$setListThemeClassNamespicks the depth class for a list out of the theme'sulDepth/olDeptharray, then tries to strip the depth classes belonging to the other levels:The removal list is built from
node.__tag + i, i.e. the literal strings"ul0","ul1","ol0"and so on. Those are not the theme's class names, they're just the tag with an index glued on, so they are never present on the element andremoveClassNamesFromElementdoes nothing.That is invisible on a freshly created element, because
createDOMstarts from a clean class list. It shows up throughupdateDOM, which reuses the existing element: when a list changes depth the new depth class is added while the old one stays, and the element ends up with two conflicting depth classes. Since these classes exist to setlist-style-typeper level (seepackages/lexical-tailwind/src/index.ts, whereulDepthmaps tolist-disc/list-[circle]/list-[square]), the list renders with whichever marker wins by CSS order rather than the one for its actual depth.$setListItemThemeClassNamesinLexicalListItemNode.tsdoes the equivalent removal correctly, pushing the real theme class names, so the two functions currently disagree.Fix
Push the actual theme class names, matching what the add path directly above already does:
normalizeClassNamesis already imported in this file.Test plan
Added
packages/lexical-list/src/__tests__/unit/ListNodeDepthThemeClass.test.ts. It builds a top level list, checks the element has the depth-1 class, then nests it one level deeper so the same element is updated in place, and checks the class list.On
mainthe second assertion fails with:With this change it passes, and the whole
lexical-listunit suite is green (11 files, 126 tests).