mirror of
https://github.com/outline/outline.git
synced 2026-11-27 16:08:58 +03:00
fix: no-op table sort should not modify document
This commit is contained in:
1 parent
85c8f83e33
commit
2a30783e72
1 file changed
+10
@@ -119,6 +119,9 @@ export function sortTable({
|
||||
// remove the header row
|
||||
const header = table.shift();
|
||||
|
||||
// column data before sort
|
||||
const columnData = table.map((row) => row[index]?.textContent ?? "");
|
||||
|
||||
// sort table data based on column at index
|
||||
table.sort((a, b) => {
|
||||
if (compareAsText) {
|
||||
@@ -137,6 +140,13 @@ export function sortTable({
|
||||
table.reverse();
|
||||
}
|
||||
|
||||
// check if column data changed, if not then do not replace table
|
||||
if (
|
||||
columnData.join() === table.map((row) => row[index]?.textContent).join()
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// add the header row back
|
||||
if (header) {
|
||||
table.unshift(header);
|
||||
|
||||
Reference in new issue
Block a user