Skip to content

Commit 50ad01d

Browse files
jackfranklinDevtools-frontend LUCI CQ
authored andcommitted
DataGrid: ensure re-sorting if data changes
This is a fix for the following scenario: 1. You sort a data grid by a column 2. The value of a cell in the sorted column changes 3. The data grid does not update to re-sort the columns with the new change The fix here forces the data grid to update its columns if we detect a mutation and we have an active sort (ensuring we don't update the columns on every mutation in the non-sorted scenario). [email protected] Bug: 449655015 Change-Id: Ib3a8495f35f849bd97e7600699fa611da932929b Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7095683 Auto-Submit: Jack Franklin <[email protected]> Commit-Queue: Jack Franklin <[email protected]> Reviewed-by: Danil Somsikov <[email protected]>
1 parent f2ceb57 commit 50ad01d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

front_end/ui/legacy/components/data_grid/DataGridElement.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,15 @@ class DataGridElement extends UI.UIUtils.HTMLElementWithLightDOMTemplate {
372372
this.#updateColumns();
373373
}
374374
this.#updateCreationNode();
375+
376+
const hadAddedNodes = mutationList.some(m => m.addedNodes.length > 0);
377+
// If we got an update, and the data grid is sorted, we need to update the
378+
// columns to maintain the sort order as the data within has changed.
379+
// However, if we have nodes added, that will trigger a sort anyway so we
380+
// don't need to re-sort again.
381+
if (this.#dataGrid.sortColumnId() !== null && !hadAddedNodes) {
382+
this.#dataGrid.dispatchEventToListeners(DataGridEvents.SORTING_CHANGED);
383+
}
375384
}
376385

377386
#editCallback(

0 commit comments

Comments
 (0)