@@ -108,17 +108,20 @@ export function TopicData({scrollContainerRef, path, database}: TopicDataProps)
108108 { pollingInterval : autoRefreshInterval } ,
109109 ) ;
110110
111+ const prevSelectedPartition = React . useRef ( selectedPartition ) ;
112+
111113 React . useEffect ( ( ) => {
114+ const selectedPartitionChanged = selectedPartition !== prevSelectedPartition . current ;
112115 const selectedPartitionData = partitions ?. find (
113116 ( { partitionId} ) => partitionId === selectedPartition ,
114117 ) ;
115118 if ( selectedPartitionData ) {
116119 let endOffset = baseEndOffset ;
117- if ( ! baseEndOffset ) {
120+ if ( ! baseEndOffset || selectedPartitionChanged ) {
118121 endOffset = safeParseNumber ( selectedPartitionData . endOffset ) ;
119122 setBaseEndOffset ( endOffset ) ;
120123 }
121- if ( ! baseOffset ) {
124+ if ( ! baseOffset || selectedPartitionChanged ) {
122125 const partitionStartOffset = safeParseNumber ( selectedPartitionData . startOffset ) ;
123126 const newStartOffset = Math . max (
124127 ( endOffset ?? 0 ) - PAGINATED_TABLE_LIMIT ,
@@ -129,7 +132,10 @@ export function TopicData({scrollContainerRef, path, database}: TopicDataProps)
129132 setBaseOffset ( newStartOffset ) ;
130133 }
131134 }
132- } , [ selectedPartition , partitions , baseOffset , baseEndOffset , startOffset , endOffset ] ) ;
135+ if ( selectedPartitionChanged ) {
136+ prevSelectedPartition . current = selectedPartition ;
137+ }
138+ } , [ selectedPartition , partitions , baseEndOffset , baseOffset ] ) ;
133139
134140 React . useEffect ( ( ) => {
135141 if ( partitions && partitions . length && isNil ( selectedPartition ) ) {
0 commit comments