fix: fix the issue where the menu scrolls back to the top after clicking an option
This commit is contained in:
parent
5f6cf1bd66
commit
7d99765589
@ -174,12 +174,13 @@ const MentionModelsButton: FC<Props> = ({ mentionModels, onMentionModel: onSelec
|
|||||||
loadPinnedModels()
|
loadPinnedModels()
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
// Scroll to the first menu item when the mode selection menu opens
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (isOpen && flatModelItems.length > 0 && itemRefs.current[0]) {
|
if (isOpen && selectedIndex > -1 && itemRefs.current[selectedIndex]) {
|
||||||
itemRefs.current[0].scrollIntoView({ block: 'nearest' })
|
requestAnimationFrame(() => {
|
||||||
|
itemRefs.current[selectedIndex]?.scrollIntoView({ block: 'nearest' })
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}, [isOpen, flatModelItems])
|
}, [isOpen, selectedIndex])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const showModelSelector = () => {
|
const showModelSelector = () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user