File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
src/packages/frontend/project/explorer/file-listing Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -167,9 +167,18 @@ export const FileListing: React.FC<Props> = ({
167
167
} ) ;
168
168
const virtuosoRef = useRef < VirtuosoHandle > ( null ) ;
169
169
170
+ const lastSelectedFileIndexRef = useRef < undefined | number > ( selected_file_index ) ;
171
+
170
172
useEffect ( ( ) => {
171
- if ( selected_file_index == null ) return ;
172
- virtuosoRef . current ?. scrollIntoView ( { index : selected_file_index } ) ;
173
+ if ( selected_file_index == null ) {
174
+ return ;
175
+ }
176
+ if ( lastSelectedFileIndexRef . current == selected_file_index - 1 ) {
177
+ virtuosoRef . current ?. scrollIntoView ( { index : selected_file_index + 1 } ) ;
178
+ } else {
179
+ virtuosoRef . current ?. scrollIntoView ( { index : selected_file_index } ) ;
180
+ }
181
+ lastSelectedFileIndexRef . current = selected_file_index ;
173
182
} , [ selected_file_index ] ) ;
174
183
175
184
function render_rows ( ) : Rendered {
You can’t perform that action at this time.
0 commit comments