Skip to content

Commit d6b212a

Browse files
committed
fix(datagrid): restore three-state sort cycle (asc, desc, none)
1 parent 6acf667 commit d6b212a

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

TablePro/Views/Results/Extensions/DataGridView+Sort.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ extension TableViewCoordinator {
1919
return
2020
}
2121

22+
if let oldDescriptor = oldDescriptors.first,
23+
oldDescriptor.key == newDescriptor.key,
24+
oldDescriptor.ascending == false,
25+
newDescriptor.ascending == true {
26+
delegate?.dataGridClearSort()
27+
return
28+
}
29+
2230
delegate?.dataGridSort(column: columnIndex, ascending: newDescriptor.ascending, isMultiSort: false)
2331
}
2432

TableProTests/Models/SortStateTests.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,4 @@ struct SortStateTests {
211211
#expect(state.isSorting == false)
212212
#expect(state.columnIndex == nil)
213213
}
214-
215-
@Test("Descending toggled to ascending stays sorting and does not clear")
216-
func descendingToAscendingStaysSorted() {
217-
var state = SortState()
218-
state.columns = [SortColumn(columnIndex: 0, direction: .descending)]
219-
state.columns[0].direction = .ascending
220-
#expect(state.isSorting == true)
221-
#expect(state.columns.count == 1)
222-
#expect(state.columns[0].direction == .ascending)
223-
}
224214
}

0 commit comments

Comments
 (0)