Commit b8bca6ba authored by Steven's avatar Steven

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
parent 2ab476ef
...@@ -38,7 +38,7 @@ export const TaskListItem: React.FC<TaskListItemProps> = ({ checked, node: _node ...@@ -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 // 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 // We need to search from the root memo content container, not just the nearest list
// to ensure nested tasks are counted in document order // 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 memo content container not found, search from document body
if (!searchRoot) { if (!searchRoot) {
......
...@@ -38,6 +38,7 @@ const MemoContent = (props: MemoContentProps) => { ...@@ -38,6 +38,7 @@ const MemoContent = (props: MemoContentProps) => {
<div className={`w-full flex flex-col justify-start items-start text-foreground ${className || ""}`}> <div className={`w-full flex flex-col justify-start items-start text-foreground ${className || ""}`}>
<div <div
ref={memoContentContainerRef} ref={memoContentContainerRef}
data-memo-content
className={cn( className={cn(
"relative w-full max-w-full wrap-break-word text-base leading-6", "relative w-full max-w-full wrap-break-word text-base leading-6",
"[&>*:last-child]:mb-0", "[&>*:last-child]:mb-0",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment