fix: automatically scroll div down in history panel
This commit is contained in:
parent
97ab9df328
commit
d3c25422d4
1 changed files with 7 additions and 1 deletions
|
|
@ -16,9 +16,15 @@ const iconMap = {
|
||||||
function History() {
|
function History() {
|
||||||
const { history, currentIndex, jumpTo } = useContext(HistoryContext);
|
const { history, currentIndex, jumpTo } = useContext(HistoryContext);
|
||||||
|
|
||||||
|
const divRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
divRef.current?.scrollIntoView(false);
|
||||||
|
}, [history]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollArea key={history.length} className="h-48 border border-zinc-200 dark:border-zinc-800 rounded-md">
|
<ScrollArea key={history.length} className="h-48 border border-zinc-200 dark:border-zinc-800 rounded-md">
|
||||||
<div className="flex flex-col">
|
<div ref={divRef} className="flex flex-col">
|
||||||
{history.map(({ name }, index) => {
|
{history.map(({ name }, index) => {
|
||||||
const IconComponent = iconMap[name as keyof typeof iconMap];
|
const IconComponent = iconMap[name as keyof typeof iconMap];
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue