Repository navigation
Conversation
…id-count change
## Description
`MarkNode.createDOM` states the rule plainly — a mark carries
`theme.markOverlap` when it has more than one id:
```ts
if (this.__ids.length > 1) {
addClassNamesToElement(element, config.theme.markOverlap);
}
```
`updateDOM` enumerated transitions instead of re-applying that rule, and only
covered two of them:
```ts
if (prevIDsCount !== nextIDsCount) {
if (prevIDsCount === 1) {
if (nextIDsCount === 2) { addClassNamesToElement(element, overlapTheme); }
} else if (nextIDsCount === 1) {
removeClassNamesFromElement(element, overlapTheme);
}
}
```
So any other crossing of the `> 1` boundary desynced the DOM from the rule:
- `1 -> 3` (or `0 -> 2`, `1 -> 4`, …) crosses into overlap but the class is
never added — the inner `nextIDsCount === 2` check fails and the `else if` is
unreachable;
- `2 -> 0` crosses out of overlap but the class is never removed, leaving
`markOverlap` on a mark with no ids.
`1 -> 3` is reachable from the shipped playground comment feature: merging
nested marks does `from.getIDs().forEach(id => to.addID(id))`
(`CommentPlugin/index.tsx`), so merging a 2-id mark into a 1-id mark lands on 3
ids in a single update and the overlap styling is silently lost. Re-creating
the same node from scratch does style it, which is the contradiction.
Compute the overlap state from the same `> 1` rule `createDOM` uses and toggle
the class only when that state changes.
## Test plan
Three new cases in `packages/lexical-mark/__tests__/unit/LexicalMarkNode.test.ts`
under a theme that defines `mark`/`markOverlap`. The `createDOM` case passes
before and after — it is the reference the two `updateDOM` cases are held to.
### Before
```
$ npx vitest run packages/lexical-mark
FAIL |unit| .../LexicalMarkNode.test.ts > MarkNode overlap theme class > updateDOM adds the overlap class when going from 1 to 3 ids
AssertionError: expected 'mk' to contain 'mk-overlap'
FAIL |unit| .../LexicalMarkNode.test.ts > MarkNode overlap theme class > updateDOM removes the overlap class when going from 2 to 0 ids
AssertionError: expected 'mk mk-overlap' not to contain 'mk-overlap'
Expected: "mk-overlap"
Received: "mk mk-overlap"
Test Files 1 failed | 2 passed (3)
Tests 2 failed | 437 passed (439)
```
### After
```
$ npx vitest run packages/lexical-mark
Test Files 3 passed (3)
Tests 439 passed (439)
```
LeSingh1
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
August 9, 2026 01:09
|
@LeSingh1 is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
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
MarkNode.createDOMstates the rule plainly — a mark carriestheme.markOverlapwhen it has more than one id:updateDOMenumerated transitions instead of re-applying that rule, and onlycovered two of them:
So any other crossing of the
> 1boundary desynced the DOM from the rule:1 -> 3(or0 -> 2,1 -> 4, …) crosses into overlap but the class isnever added — the inner
nextIDsCount === 2check fails and theelse ifisunreachable;
2 -> 0crosses out of overlap but the class is never removed, leavingmarkOverlapon a mark with no ids.1 -> 3is reachable from the shipped playground comment feature: mergingnested marks does
from.getIDs().forEach(id => to.addID(id))(
CommentPlugin/index.tsx), so merging a 2-id mark into a 1-id mark lands on 3ids in a single update and the overlap styling is silently lost. Re-creating
the same node from scratch does style it, which is the contradiction.
Compute the overlap state from the same
> 1rulecreateDOMuses and togglethe class only when that state changes.
Test plan
Three new cases in
packages/lexical-mark/__tests__/unit/LexicalMarkNode.test.tsunder a theme that defines
mark/markOverlap. ThecreateDOMcase passesbefore and after — it is the reference the two
updateDOMcases are held to.Before
After