@@ -19,7 +19,7 @@ import {
1919 Tooltip ,
2020 Typography ,
2121} from '@mui/material' ;
22- import React , { useEffect , useState } from 'react' ;
22+ import React , { useEffect , useState , useRef } from 'react' ; // <-- Importa useRef
2323import { useSnackbar } from '../../providers/SnackProvider' ;
2424import BaseModal from './BaseModal' ;
2525
@@ -44,6 +44,7 @@ const KVStoreModal: React.FC<Props> = ({
4444 > ( [ ] ) ;
4545 const [ loading , setLoading ] = useState ( false ) ;
4646 const { showError } = useSnackbar ( ) ;
47+ const formContainerRef = useRef < HTMLDivElement | null > ( null ) ;
4748
4849 useEffect ( ( ) => {
4950 if ( open ) {
@@ -54,8 +55,7 @@ const KVStoreModal: React.FC<Props> = ({
5455 setFormData ( preparedData ) ;
5556 setPendingChanges ( [ ] ) ;
5657 }
57- // eslint-disable-next-line react-hooks/exhaustive-deps
58- } , [ open ] ) ;
58+ } , [ open , initialData ] ) ;
5959
6060 const updatePendingChanges = ( key : string , value : string ) => {
6161 setPendingChanges ( ( prev ) => {
@@ -125,6 +125,12 @@ const KVStoreModal: React.FC<Props> = ({
125125
126126 const handleAddField = ( ) => {
127127 setFormData ( ( prev ) => [ ...prev , { key : '' , value : '' } ] ) ;
128+
129+ setTimeout ( ( ) => {
130+ formContainerRef . current ?. lastElementChild ?. scrollIntoView ( {
131+ behavior : 'smooth' ,
132+ } ) ;
133+ } , 100 ) ;
128134 } ;
129135
130136 const handleSave = async ( ) => {
@@ -169,6 +175,7 @@ const KVStoreModal: React.FC<Props> = ({
169175 Edit KVStore
170176 </ Typography >
171177 < Box
178+ ref = { formContainerRef }
172179 sx = { {
173180 maxHeight : '400px' ,
174181 overflowY : 'auto' ,
0 commit comments