Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions components/build-model/PatricGenomesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,21 @@ export default function PatricGenomesTable({ onSelectGenome, disabled = false }:
[disabled, onSelectGenome],
);

const handleToolbarApplyFilterModel = (model: GridFilterModel) => {
// Store the full multi-filter from the toolbar (bypasses grid truncation)
committedFilterItemsRef.current = model.items as GridFilterItem[];
committedLogicOperatorRef.current = model.logicOperator;

// Also update the local filterModel so the UI stays in sync
setFilterModel({
items: model.items,
logicOperator: model.logicOperator,
quickFilterValues: model.quickFilterValues ?? [],
quickFilterLogicOperator: model.quickFilterLogicOperator,
});
setPaginationModel((prev) => ({ ...prev, page: 0 }));
};
Comment on lines +132 to +145

return (
<Box>
{error && (
Expand All @@ -155,8 +170,14 @@ export default function PatricGenomesTable({ onSelectGenome, disabled = false }:
setFilterModel((prev) => {
const committed = committedFilterItemsRef.current;
const incomingItems = (next.items ?? []) as GridFilterItem[];
// Only keep committed filters when:
// 1. We have committed items
// 2. Incoming count is LESS than committed (truncation)
// 3. Incoming count is > 0 (not an intentional clear)
const shouldKeepCommitted =
committed.length > 0 && incomingItems.length < committed.length;
committed.length > 0 &&
incomingItems.length < committed.length &&
incomingItems.length > 0;
return {
items: shouldKeepCommitted ? committed : incomingItems,
logicOperator: shouldKeepCommitted
Expand All @@ -167,14 +188,16 @@ export default function PatricGenomesTable({ onSelectGenome, disabled = false }:
};
});
const incomingItems = (next.items ?? []) as GridFilterItem[];
if (incomingItems.length >= committedFilterItemsRef.current.length) {
// Only update committed refs if we're not clearing (incoming has items or was truncation)
if (incomingItems.length > 0 || incomingItems.length >= committedFilterItemsRef.current.length) {
Comment on lines +191 to +192
committedFilterItemsRef.current = incomingItems;
committedLogicOperatorRef.current = next.logicOperator;
}
setPaginationModel((prev) => ({ ...prev, page: 0 }));
}}
showToolbar
slots={{ toolbar: DataControlHeader }}
slotProps={{ toolbar: { onApplyFilterModel: handleToolbarApplyFilterModel } }}
hideFooter
disableRowSelectionOnClick
disableColumnMenu
Expand Down
10 changes: 10 additions & 0 deletions components/layout/DataControlHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,16 @@ function ToolbarFilterEditor({ onApplyFilterModel }: { onApplyFilterModel?: (mod
// Pass source:'toolbar' so handlers know this is an explicit user action,
// not a Community Edition truncation event from the grid itself.
onApplyFilterModel(fullModel, { source: 'toolbar' });

// Also update the grid's internal model so features like GridHighlightText
// and the filter button badge reflect the current search state.
// We pass a truncated model to avoid Community Edition limits.
apiRef.current.setFilterModel({
items: filledItems.slice(0, 1),
logicOperator: draftLogicOperator,
quickFilterValues,
quickFilterLogicOperator,
});
} else {
// Client-side page: let the grid apply item[0] for native row filtering.
// Rows 2+ won't be applied by the grid, but they are stored in committedItemsRef.
Expand Down
Loading