fix(web): scope task list item index to memo content container

The closest() selector was targeting a CSS class that never existed on
the container, causing fallback to document.body and collecting task
items across all visible memos. This caused index collisions when
multiple memos with todo lists were on the page.

Adds data-memo-content attribute to the container and updates the
selector accordingly.

Fixes #5635
This commit is contained in:
Steven 2026-02-22 13:20:29 +08:00
parent 2ab476ef2e
commit b8bca6bacf
2 changed files with 2 additions and 1 deletions

View File

@ -38,7 +38,7 @@ export const TaskListItem: React.FC<TaskListItemProps> = ({ checked, node: _node
// Fallback: Calculate index by counting all task list items in the entire memo
// We need to search from the root memo content container, not just the nearest list
// to ensure nested tasks are counted in document order
let searchRoot = listItem.closest('[class*="memo-content"], [class*="MemoContent"]');
let searchRoot = listItem.closest("[data-memo-content]");
// If memo content container not found, search from document body
if (!searchRoot) {

View File

@ -38,6 +38,7 @@ const MemoContent = (props: MemoContentProps) => {
<div className={`w-full flex flex-col justify-start items-start text-foreground ${className || ""}`}>
<div
ref={memoContentContainerRef}
data-memo-content
className={cn(
"relative w-full max-w-full wrap-break-word text-base leading-6",
"[&>*:last-child]:mb-0",