@@ -108,17 +108,20 @@ export function TopicData({scrollContainerRef, path, database}: TopicDataProps)
108
108
{ pollingInterval : autoRefreshInterval } ,
109
109
) ;
110
110
111
+ const prevSelectedPartition = React . useRef ( selectedPartition ) ;
112
+
111
113
React . useEffect ( ( ) => {
114
+ const selectedPartitionChanged = selectedPartition !== prevSelectedPartition . current ;
112
115
const selectedPartitionData = partitions ?. find (
113
116
( { partitionId} ) => partitionId === selectedPartition ,
114
117
) ;
115
118
if ( selectedPartitionData ) {
116
119
let endOffset = baseEndOffset ;
117
- if ( ! baseEndOffset ) {
120
+ if ( ! baseEndOffset || selectedPartitionChanged ) {
118
121
endOffset = safeParseNumber ( selectedPartitionData . endOffset ) ;
119
122
setBaseEndOffset ( endOffset ) ;
120
123
}
121
- if ( ! baseOffset ) {
124
+ if ( ! baseOffset || selectedPartitionChanged ) {
122
125
const partitionStartOffset = safeParseNumber ( selectedPartitionData . startOffset ) ;
123
126
const newStartOffset = Math . max (
124
127
( endOffset ?? 0 ) - PAGINATED_TABLE_LIMIT ,
@@ -129,7 +132,10 @@ export function TopicData({scrollContainerRef, path, database}: TopicDataProps)
129
132
setBaseOffset ( newStartOffset ) ;
130
133
}
131
134
}
132
- } , [ selectedPartition , partitions , baseOffset , baseEndOffset , startOffset , endOffset ] ) ;
135
+ if ( selectedPartitionChanged ) {
136
+ prevSelectedPartition . current = selectedPartition ;
137
+ }
138
+ } , [ selectedPartition , partitions , baseEndOffset , baseOffset ] ) ;
133
139
134
140
React . useEffect ( ( ) => {
135
141
if ( partitions && partitions . length && isNil ( selectedPartition ) ) {
0 commit comments