Repository navigation
Conversation
LeSingh1
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
August 9, 2026 05:58
|
@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. |
Collaborator
|
Simple one-character typo ( |
Collaborator
|
The tests fail tsc, needs an $assertNodeType or equivalent |
…top block
## Description
`$canShowPlaceholder` documents itself as "If anything is in the root the
placeholder should not be shown". Its innermost loop is meant to reject a top
block that holds any non-text child, but it indexes with the *outer* loop's
variable:
```js
for (let s = 0; s < topBlockChildrenLength; s++) {
const child = topBlockChildren[i]; // `i`, not `s`
if (!$isTextNode(child)) {
return false;
}
}
```
`s` is declared and incremented but never read, which is what gives the typo
away. `i` indexes the loop over the *root's* children, and the earlier
`if (childrenLength > 1) { return false; }` guard means it is always `0`. So
the loop tests `topBlockChildren[0]` N times and never looks at index 1 or
beyond — the one thing it exists to do.
A paragraph whose children are `[TextNode(""), <inline DecoratorNode>]`
therefore reports that the placeholder may be shown, and the placeholder
renders on top of real content. The root's text content is genuinely `""` (a
decorator contributes no text), so the `$isRootTextContentEmpty(isComposing,
false)` gate legitimately passes and the child scan is the only thing standing
between that document and a wrong placeholder.
Reaching it needs the TextNode at index 0 to survive reconciliation: a *simple*
empty TextNode is removed, which would shuffle the decorator to index 0 and
mask the bug. `token` and `segmented` nodes are not simple text and do survive,
which is the shape the test uses.
## Test plan
New unit test `packages/lexical-text/src/__tests__/unit/canShowPlaceholder.test.ts`.
It asserts the premise (the text node survived, root text content is `""`)
before asserting the result, so the test cannot silently stop exercising the
scan. The last three cases are controls — decorator first, empty paragraph, and
a paragraph of only empty text nodes — and pass before and after.
### Before
```
$ npx vitest run packages/lexical-text
× is false when a decorator follows an empty token text node 32ms
× is false when a decorator follows an empty segmented text node 4ms
× is false when the decorator is several positions along 3ms
AssertionError: expected true to be false // Object.is equality
Tests 3 failed | 3 passed (6)
```
### After
```
$ npx vitest run packages/lexical-text
Test Files 1 passed (1)
Tests 6 passed (6)
```
LeSingh1
force-pushed
the
text-placeholder-loop-index
branch
from
August 9, 2026 23:15
2b0216c to
32d86db
Compare
Contributor
Author
|
Fixed in 32d86db — Sorry for the churn, and thanks for catching it — I had run the test suite but not the typecheck on this branch. |
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
$canShowPlaceholderdocuments itself as "If anything is in the root theplaceholder should not be shown". Its innermost loop is meant to reject a top
block that holds any non-text child, but it indexes with the outer loop's
variable:
sis declared and incremented but never read, which is what gives the typoaway.
iindexes the loop over the root's children, and the earlierif (childrenLength > 1) { return false; }guard means it is always0. Sothe loop tests
topBlockChildren[0]N times and never looks at index 1 orbeyond — the one thing it exists to do.
A paragraph whose children are
[TextNode(""), <inline DecoratorNode>]therefore reports that the placeholder may be shown, and the placeholder
renders on top of real content. The root's text content is genuinely
""(adecorator contributes no text), so the
$isRootTextContentEmpty(isComposing, false)gate legitimately passes and the child scan is the only thing standingbetween that document and a wrong placeholder.
Reaching it needs the TextNode at index 0 to survive reconciliation: a simple
empty TextNode is removed, which would shuffle the decorator to index 0 and
mask the bug.
tokenandsegmentednodes are not simple text and do survive,which is the shape the test uses.
Test plan
New unit test
packages/lexical-text/src/__tests__/unit/canShowPlaceholder.test.ts.It asserts the premise (the text node survived, root text content is
"")before asserting the result, so the test cannot silently stop exercising the
scan. The last three cases are controls — decorator first, empty paragraph, and
a paragraph of only empty text nodes — and pass before and after.
Before
After