Skip to content

Commit 526752f

Browse files
authored
Merge pull request #1396 from VEuPathDB/fix-1395-mesa-text-search
Make links searchable in tables, and sort out search on paged tables
2 parents 777e144 + 82cdcae commit 526752f

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

packages/libs/eda/src/lib/core/components/filter/TableFilter.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,13 @@ export function TableFilter({
232232
analysisState.setVariableUISettings((currentState) => ({
233233
...currentState,
234234
[uiStateKey]: {
235-
...uiState,
235+
...currentState[uiStateKey],
236236
sort,
237237
currentPage: 1,
238238
},
239239
}));
240240
},
241-
[analysisState, uiStateKey, uiState]
241+
[analysisState, uiStateKey]
242242
);
243243

244244
const handleSearch = useCallback(
@@ -254,39 +254,39 @@ export function TableFilter({
254254
analysisState.setVariableUISettings((currentState) => ({
255255
...currentState,
256256
[uiStateKey]: {
257-
...uiState,
257+
...currentState[uiStateKey],
258258
searchTerm,
259259
...(shouldResetPaging ? { currentPage: 1 } : {}),
260260
},
261261
}));
262262
},
263-
[analysisState, uiStateKey, uiState]
263+
[analysisState, uiStateKey]
264264
);
265265

266266
const handlePagination = useCallback(
267267
(_: unknown, currentPage: number) => {
268268
analysisState.setVariableUISettings((currentState) => ({
269269
...currentState,
270270
[uiStateKey]: {
271-
...uiState,
271+
...currentState[uiStateKey],
272272
currentPage,
273273
},
274274
}));
275275
},
276-
[analysisState, uiStateKey, uiState]
276+
[analysisState, uiStateKey]
277277
);
278278

279279
const handleRowsPerPage = useCallback(
280280
(_: unknown, rowsPerPage: number) => {
281281
analysisState.setVariableUISettings((currentState) => ({
282282
...currentState,
283283
[uiStateKey]: {
284-
...uiState,
284+
...currentState[uiStateKey],
285285
rowsPerPage,
286286
},
287287
}));
288288
},
289-
[analysisState, uiStateKey, uiState]
289+
[analysisState, uiStateKey]
290290
);
291291

292292
const allValues = useMemo(() => {

packages/libs/wdk-client/src/Views/Records/RecordTable/RecordTable.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,9 @@ class RecordTable extends Component {
264264
)
265265
: displayableAttributes;
266266
const filteredRows = sortedMesaRows.filter((row) => {
267-
return searchableAttributes.some((attr) => regex.test(row[attr.name]));
267+
return searchableAttributes.some((attr) =>
268+
regex.test(row[attr.name].text ?? row[attr.name])
269+
);
268270
});
269271

270272
const tableState = {

packages/sites/ortho-site/webapp/wdkCustomization/js/client/records/Sequences.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,11 @@ export function RecordTable_Sequences(
339339
[mesaColumns]
340340
);
341341

342+
const handleSearchQueryChange = useCallback((query: string) => {
343+
setSearchQuery(query);
344+
setTablePageNumber(1);
345+
}, []);
346+
342347
const handleSpeciesSelection = useCallback((species: string[]) => {
343348
setSelectedSpecies(species);
344349
setTablePageNumber(1);
@@ -742,7 +747,7 @@ export function RecordTable_Sequences(
742747
<RecordFilter
743748
key={`text-search-${resetCounter}`}
744749
searchTerm={searchQuery}
745-
onSearchTermChange={setSearchQuery}
750+
onSearchTermChange={handleSearchQueryChange}
746751
recordDisplayName="Proteins"
747752
filterAttributes={filterAttributes}
748753
selectedColumnFilters={volatileSelectedColumnFilters}

0 commit comments

Comments
 (0)