fix(data-table): prevent unnecessary page reset on data change

Updated the data table component to only reset the page index to 0 when it is not already at 0, improving user experience during data updates. Additionally, refactored the module selection logic to prune invalid selected module IDs more efficiently, enhancing the overall functionality of the module management interface.
This commit is contained in:
Denozordec
2026-07-01 00:27:39 +07:00
parent 1c7152a285
commit 07ee6acddb
2 changed files with 13 additions and 3 deletions
@@ -73,7 +73,7 @@
$effect(() => {
rows;
pageIndex = 0;
if (pageIndex !== 0) pageIndex = 0;
});
function toggleSort(col: DataTableColumn<T>) {
+12 -2
View File
@@ -105,9 +105,19 @@
void queryClient.invalidateQueries({ queryKey: modulesKeys.all });
}
$effect(() => {
function pruneSelectedModuleIds() {
const validIds = new Set(rows.map((item) => item.id));
selectedModuleIds = new Set([...selectedModuleIds].filter((id) => validIds.has(id)));
for (const id of selectedModuleIds) {
if (!validIds.has(id)) {
selectedModuleIds = new Set([...selectedModuleIds].filter((id) => validIds.has(id)));
return;
}
}
}
$effect(() => {
rows;
pruneSelectedModuleIds();
});
function toggleModuleSelection(id: string) {