mirror of https://github.com/usememos/memos.git
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:
parent
2ab476ef2e
commit
b8bca6bacf
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Reference in New Issue