From aec190245b7744245197dd29a83ba5a550309c6d Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Fri, 30 Jun 2023 19:07:36 -0400 Subject: [PATCH] fix: No scroll to anchor if already exists --- app/editor/index.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/editor/index.tsx b/app/editor/index.tsx index cab6dcf48..c812e32ec 100644 --- a/app/editor/index.tsx +++ b/app/editor/index.tsx @@ -879,7 +879,13 @@ const observe = ( callback(match as HTMLElement); } }); - observer.observe(targetNode, { childList: true, subtree: true }); + + if (targetNode.querySelector(selector)) { + callback(targetNode.querySelector(selector) as HTMLElement); + } else { + observer.observe(targetNode, { childList: true, subtree: true }); + } + return observer; };