Skip to content

Commit 818556a

Browse files
fix(application-runners): scroll to new topic input (issuer #2402) (#2406)
1 parent 71ef33c commit 818556a

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

apps/ai-dial-admin/src/components/Common/Lists/CheckboxList.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FC, useCallback, useEffect, useState } from 'react';
1+
import { FC, useCallback, useEffect, useRef, useState } from 'react';
22
import NewItem from '@/src/components/Common/Multiselect/Modal/NewItem';
33
import { DialCheckbox, DialNeutralButton } from '@epam/ai-dial-ui-kit';
44
import { IconPlus } from '@tabler/icons-react';
@@ -23,6 +23,8 @@ const CheckboxList: FC<Props> = ({
2323
addTitle,
2424
addPlaceholder,
2525
}) => {
26+
const newItemsContainer = useRef<HTMLUListElement | null>(null);
27+
2628
const [list, setList] = useState<string[]>(items);
2729
const [newList, setNewList] = useState<string[]>([]);
2830

@@ -73,9 +75,21 @@ const CheckboxList: FC<Props> = ({
7375
setNewList((prev) => [...prev, '']);
7476
}, []);
7577

78+
useEffect(() => {
79+
const container = newItemsContainer.current;
80+
if (container && container.scrollHeight > container.clientHeight) {
81+
setTimeout(() => {
82+
container.scrollTo({
83+
top: container.scrollHeight,
84+
behavior: 'smooth',
85+
});
86+
});
87+
}
88+
}, [newList.length]);
89+
7690
return (
7791
<>
78-
<ul className="flex flex-col gap-y-2 overflow-auto flex-1 min-h-0">
92+
<ul className="flex flex-col gap-y-2 overflow-auto flex-1 min-h-0" ref={newItemsContainer}>
7993
{list.map((item, index) => (
8094
<li key={`item_${index}`}>
8195
<DialCheckbox

0 commit comments

Comments
 (0)