Skip to content

Commit 848f754

Browse files
authored
fix(TopicData): reset filters on partition change (#2567)
1 parent a9670eb commit 848f754

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

src/containers/Tenant/Diagnostics/TopicData/TopicData.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,14 @@ export function TopicData({scrollContainerRef, path, database}: TopicDataProps)
199199
}
200200
}, [handleSelectedOffsetChange, handleStartTimestampChange, topicDataFilter]);
201201

202+
const handlePartitionChange = React.useCallback(
203+
(value: string[]) => {
204+
handleSelectedPartitionChange(value[0]);
205+
resetFilters();
206+
},
207+
[handleSelectedPartitionChange, resetFilters],
208+
);
209+
202210
const scrollToOffset = React.useCallback(
203211
(newOffset: number) => {
204212
const scrollTop = (newOffset - (baseOffset ?? 0)) * DEFAULT_TABLE_ROW_HEIGHT;
@@ -241,6 +249,7 @@ export function TopicData({scrollContainerRef, path, database}: TopicDataProps)
241249
key={controlsKey}
242250
columnsToSelect={columnsToSelect}
243251
handleSelectedColumnsUpdate={setColumns}
252+
handlePartitionChange={handlePartitionChange}
244253
partitions={partitions}
245254
partitionsLoading={partitionsLoading}
246255
partitionsError={partitionsError}
@@ -261,6 +270,7 @@ export function TopicData({scrollContainerRef, path, database}: TopicDataProps)
261270
setColumns,
262271
startOffset,
263272
truncated,
273+
handlePartitionChange,
264274
]);
265275

266276
const renderEmptyDataMessage = () => {

src/containers/Tenant/Diagnostics/TopicData/TopicDataControls/TopicDataControls.tsx

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@ interface TopicDataControlsProps {
4141
endOffset?: number;
4242
truncatedData?: boolean;
4343
scrollToOffset: (offset: number) => void;
44+
handlePartitionChange?: (value: string[]) => void;
4445
}
4546

4647
export function TopicDataControls({
4748
columnsToSelect,
4849
handleSelectedColumnsUpdate,
50+
handlePartitionChange,
4951

5052
startOffset,
5153
endOffset,
@@ -55,39 +57,21 @@ export function TopicDataControls({
5557
scrollToOffset,
5658
truncatedData,
5759
}: TopicDataControlsProps) {
58-
const {
59-
selectedPartition,
60-
handleSelectedPartitionChange: handleSelectedPartitionParamChange,
61-
handleSelectedOffsetChange,
62-
handleStartTimestampChange,
63-
} = useTopicDataQueryParams();
60+
const {selectedPartition} = useTopicDataQueryParams();
6461

6562
const partitionsToSelect = partitions?.map(({partitionId}) => ({
6663
content: String(partitionId),
6764
value: String(partitionId),
6865
}));
6966

70-
const handleSelectedPartitionChange = React.useCallback(
71-
(value: string[]) => {
72-
handleSelectedPartitionParamChange(value[0]);
73-
handleSelectedOffsetChange(undefined);
74-
handleStartTimestampChange(undefined);
75-
},
76-
[
77-
handleSelectedPartitionParamChange,
78-
handleStartTimestampChange,
79-
handleSelectedOffsetChange,
80-
],
81-
);
82-
8367
return (
8468
<React.Fragment>
8569
<Select
8670
className={b('partition-select')}
8771
label={i18n('label_partition-id')}
8872
options={partitionsToSelect}
8973
value={selectedPartition ? [selectedPartition] : undefined}
90-
onUpdate={handleSelectedPartitionChange}
74+
onUpdate={handlePartitionChange}
9175
filterable={partitions && partitions.length > 5}
9276
disabled={!partitions || !partitions.length}
9377
errorPlacement="inside"

0 commit comments

Comments
 (0)