|
@@ -25,18 +25,15 @@ const SearchResultContent: FC<Props> = (props: Props) => {
|
|
|
const contentRef = useRef(null);
|
|
const contentRef = useRef(null);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
- // reset state
|
|
|
|
|
- if (isRevisionBodyRendered) {
|
|
|
|
|
- const searchResultPageContent = contentRef.current as HTMLElement | null;
|
|
|
|
|
- if (searchResultPageContent !== null) {
|
|
|
|
|
- const highlightedWord = searchResultPageContent?.querySelector('.highlighted-keyword') as HTMLElement | null;
|
|
|
|
|
- if (highlightedWord != null) {
|
|
|
|
|
- smoothScrollIntoView(highlightedWord, SCROLL_OFFSET_TOP, searchResultPageContent);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // if isRevisionBodyRendered is false then do nothing
|
|
|
|
|
+ if (isRevisionBodyRendered && contentRef.current != null) {
|
|
|
|
|
+ const searchResultPageContent = contentRef.current as HTMLElement;
|
|
|
|
|
+ const highlightedWord = searchResultPageContent.querySelector('.highlighted-keyword') as HTMLElement | null;
|
|
|
|
|
+ if (highlightedWord != null) {
|
|
|
|
|
+ smoothScrollIntoView(highlightedWord, SCROLL_OFFSET_TOP, searchResultPageContent);
|
|
|
}
|
|
}
|
|
|
setIsRevisionBodyRendered(false);
|
|
setIsRevisionBodyRendered(false);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}, [isRevisionBodyRendered, contentRef.current]);
|
|
}, [isRevisionBodyRendered, contentRef.current]);
|
|
|
|
|
|
|
|
const page = props.focusedSearchResultData?.pageData;
|
|
const page = props.focusedSearchResultData?.pageData;
|