|
@@ -1,4 +1,4 @@
|
|
|
-import { useEffect, useState } from "react";
|
|
|
|
|
|
|
+import { useEffect, useRef, useState } from "react";
|
|
|
import { useAppSelector } from "../../../hooks";
|
|
import { useAppSelector } from "../../../hooks";
|
|
|
import { prInfo } from "../../../reducers/pr-load";
|
|
import { prInfo } from "../../../reducers/pr-load";
|
|
|
|
|
|
|
@@ -20,6 +20,8 @@ const SuggestionFocusWidget = ({
|
|
|
}: IWidget) => {
|
|
}: IWidget) => {
|
|
|
const pr = useAppSelector(prInfo);
|
|
const pr = useAppSelector(prInfo);
|
|
|
const [highlight, setHighlight] = useState(false);
|
|
const [highlight, setHighlight] = useState(false);
|
|
|
|
|
+ const divRef = useRef<HTMLDivElement>(null);
|
|
|
|
|
+
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
if (pr) {
|
|
if (pr) {
|
|
|
if (
|
|
if (
|
|
@@ -30,6 +32,11 @@ const SuggestionFocusWidget = ({
|
|
|
channelId === pr.channel.id
|
|
channelId === pr.channel.id
|
|
|
) {
|
|
) {
|
|
|
setHighlight(true);
|
|
setHighlight(true);
|
|
|
|
|
+ divRef.current?.scrollIntoView({
|
|
|
|
|
+ behavior: "smooth",
|
|
|
|
|
+ block: "center",
|
|
|
|
|
+ inline: "nearest",
|
|
|
|
|
+ });
|
|
|
} else {
|
|
} else {
|
|
|
setHighlight(false);
|
|
setHighlight(false);
|
|
|
}
|
|
}
|
|
@@ -38,14 +45,15 @@ const SuggestionFocusWidget = ({
|
|
|
}
|
|
}
|
|
|
}, [book, channelId, end, para, pr, start]);
|
|
}, [book, channelId, end, para, pr, start]);
|
|
|
return (
|
|
return (
|
|
|
- <span
|
|
|
|
|
|
|
+ <div
|
|
|
|
|
+ ref={divRef}
|
|
|
style={{
|
|
style={{
|
|
|
backgroundColor: highlight ? "rgb(255 255 0 / 20%)" : undefined,
|
|
backgroundColor: highlight ? "rgb(255 255 0 / 20%)" : undefined,
|
|
|
width: "100%",
|
|
width: "100%",
|
|
|
}}
|
|
}}
|
|
|
>
|
|
>
|
|
|
{children}
|
|
{children}
|
|
|
- </span>
|
|
|
|
|
|
|
+ </div>
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
|
|
|