MDL-69241 lib: Reset dynamic tables to page 1 when filtering or sorting
This ensures consistency and that the page will always exist, which may not be true for later pages if applying filters returns fewer results.
This commit is contained in:
Vendored
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -156,14 +156,6 @@ export const updateTable = (tableRoot, {
|
||||
tableRoot.dataset.tableLastInitial = lastInitial;
|
||||
}
|
||||
|
||||
if (pageNumber !== null) {
|
||||
if (tableRoot.dataset.tablePageNumber != pageNumber) {
|
||||
tableConfigChanged = true;
|
||||
}
|
||||
|
||||
tableRoot.dataset.tablePageNumber = pageNumber;
|
||||
}
|
||||
|
||||
if (pageSize !== null) {
|
||||
if (tableRoot.dataset.tablePageSize != pageSize) {
|
||||
tableConfigChanged = true;
|
||||
@@ -183,6 +175,12 @@ export const updateTable = (tableRoot, {
|
||||
tableRoot.dataset.tableFilters = filterJson;
|
||||
}
|
||||
|
||||
// Reset to page 1 when table content is being altered by filtering or sorting.
|
||||
// This ensures the table page being loaded always exists, and gives a consistent experience.
|
||||
if (tableConfigChanged) {
|
||||
pageNumber = 1;
|
||||
}
|
||||
|
||||
// Update hidden columns.
|
||||
if (hiddenColumns) {
|
||||
const columnJson = JSON.stringify(hiddenColumns);
|
||||
@@ -194,6 +192,14 @@ export const updateTable = (tableRoot, {
|
||||
tableRoot.dataset.tableHiddenColumns = columnJson;
|
||||
}
|
||||
|
||||
if (pageNumber !== null) {
|
||||
if (tableRoot.dataset.tablePageNumber != pageNumber) {
|
||||
tableConfigChanged = true;
|
||||
}
|
||||
|
||||
tableRoot.dataset.tablePageNumber = pageNumber;
|
||||
}
|
||||
|
||||
// Refresh.
|
||||
if (refreshContent && tableConfigChanged) {
|
||||
return refreshTableContent(tableRoot)
|
||||
|
||||
Reference in New Issue
Block a user