Merge branch 'MDL-69241-master' of git://github.com/mickhawkins/moodle

This commit is contained in:
Andrew Nicols 2020-08-13 08:27:01 +08:00
commit dec6eebdaa
3 changed files with 16 additions and 10 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -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)