Skip to content

Commit 2156e77

Browse files
committed
chore: fix arrow down when a collapsed collapsible is the last node
1 parent 1bca31c commit 2156e77

File tree

1 file changed

+10
-4
lines changed
  • packages/web/src/javascripts/Components/SuperEditor/Plugins/CollapsiblePlugin

1 file changed

+10
-4
lines changed

packages/web/src/javascripts/Components/SuperEditor/Plugins/CollapsiblePlugin/index.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
KEY_ARROW_LEFT_COMMAND,
2828
KEY_ARROW_RIGHT_COMMAND,
2929
KEY_ARROW_UP_COMMAND,
30+
LexicalNode,
3031
NodeKey,
3132
} from 'lexical'
3233
import { useEffect } from 'react'
@@ -83,11 +84,16 @@ export default function CollapsiblePlugin(): JSX.Element | null {
8384
if ($isCollapsibleContainerNode(container)) {
8485
const parent = container.getParent()
8586
if (parent !== null && parent.getLastChild() === container) {
86-
const lastDescendant = container.getLastDescendant()
87+
const titleParagraph = container.getFirstDescendant<LexicalNode>()
88+
const contentParagraph = container.getLastDescendant<LexicalNode>()
89+
8790
if (
88-
lastDescendant !== null &&
89-
selection.anchor.key === lastDescendant.getKey() &&
90-
selection.anchor.offset === lastDescendant.getTextContentSize()
91+
(contentParagraph !== null &&
92+
selection.anchor.key === contentParagraph.getKey() &&
93+
selection.anchor.offset === contentParagraph.getTextContentSize()) ||
94+
(titleParagraph !== null &&
95+
selection.anchor.key === titleParagraph.getKey() &&
96+
selection.anchor.offset === titleParagraph.getTextContentSize())
9197
) {
9298
container.insertAfter($createParagraphNode())
9399
}

0 commit comments

Comments
 (0)