From 401f28847c49058334c3e2035cbdbb424d7e2575 Mon Sep 17 00:00:00 2001 From: Huang Xin Date: Thu, 22 May 2025 14:08:52 +0800 Subject: [PATCH] fix: add location only when toc item is at the same level as the section (#1220) --- apps/readest-app/src/utils/toc.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/readest-app/src/utils/toc.ts b/apps/readest-app/src/utils/toc.ts index d487ce53..a2ce6698 100644 --- a/apps/readest-app/src/utils/toc.ts +++ b/apps/readest-app/src/utils/toc.ts @@ -75,7 +75,11 @@ const updateTocData = ( const section = sections[id]; if (section) { item.cfi = section.cfi; - item.location = section.location; + // Add location only when toc item is at the same level as the section + // otherwise the location will not be accurate + if (id === item.href) { + item.location = section.location; + } } } if (item.subitems) {