Skip to content

Commit 9dd67e0

Browse files
committed
Fix a bug with section highlighting when the last inline isn't shown at all
1 parent 93132ac commit 9dd67e0

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

content_editor/static/content_editor/content_editor.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,19 @@
413413
indent = nextIndent
414414
}
415415

416-
while (stack.length) {
417-
closeSection(inlines[inlines.length - 1])
416+
if (stack.length) {
417+
// Cannot just use the last inline, it may be hidden. Find the last
418+
// inline and use it for finding the place where all open sections
419+
// should be closed visually.
420+
let lastVisibleIndex = inlines.length - 1
421+
while (
422+
inlines[lastVisibleIndex].classList.contains("content-editor-hide")
423+
) {
424+
--lastVisibleIndex
425+
}
426+
while (stack.length) {
427+
closeSection(inlines[lastVisibleIndex])
428+
}
418429
}
419430

420431
for (const section of sectionsMap.values()) {

0 commit comments

Comments
 (0)