Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
flocked committed Jul 13, 2024
1 parent 55be28c commit f0a62b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ open class CollectionViewDiffableDataSource<Section: Identifiable & Hashable, El
var section: Section? = nil
var selectionElement: Element? = nil
if let element = elementsToDelete.first {
if let indexPath = indexPath(for: element), indexPath.item > 0, let element = self.element(for: IndexPath(item: indexPath.item - 1, section: indexPath.section)), !elementsToDelete.contains(element) {
if let indexPath = self.indexPath(for: element), indexPath.item > 0, let element = self.element(for: IndexPath(item: indexPath.item - 1, section: indexPath.section)), !elementsToDelete.contains(element) {
selectionElement = element
} else {
section = self.section(for: element)
Expand All @@ -241,20 +241,20 @@ open class CollectionViewDiffableDataSource<Section: Identifiable & Hashable, El
let transaction = self.deletionTransaction(elementsToDelete)
self.deletingHandlers.willDelete?(elementsToDelete, transaction)
QuicklookPanel.shared.close()
self.apply(transaction.finalSnapshot, deletingHandlers.animates ? .animated : .withoutAnimation)
deletingHandlers.didDelete?(elementsToDelete, transaction)
self.apply(transaction.finalSnapshot, self.deletingHandlers.animates ? .animated : .withoutAnimation)
self.deletingHandlers.didDelete?(elementsToDelete, transaction)

if collectionView.allowsEmptySelection == false, collectionView.selectionIndexPaths.isEmpty {
if !self.collectionView.allowsEmptySelection, self.collectionView.selectionIndexPaths.isEmpty {
var selectionIndexPath: IndexPath?
if let element = selectionElement, let indexPath = indexPath(for: element) {
if let element = selectionElement, let indexPath = self.indexPath(for: element) {
selectionIndexPath = indexPath
} else if let section = section, let element = elements(for: section).first, let indexPath = indexPath(for: element) {
} else if let section = section, let element = self.elements(for: section).first, let indexPath = self.indexPath(for: element) {
selectionIndexPath = indexPath
} else if let item = currentSnapshot.itemIdentifiers.first, let indexPath = indexPath(for: item) {
} else if let item = self.currentSnapshot.itemIdentifiers.first, let indexPath = self.indexPath(for: item) {
selectionIndexPath = indexPath
}
if let indexPath = selectionIndexPath {
collectionView.selectItems(at: [indexPath], scrollPosition: [])
self.collectionView.selectItems(at: [indexPath], scrollPosition: [])
}
}
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ open class TableViewDiffableDataSource<Section, Item>: NSObject, NSTableViewData
self.deletingHandlers.willDelete?(itemsToDelete, transaction)
QuicklookPanel.shared.close()
self.apply(transaction.finalSnapshot, self.deletingHandlers.animates ? .animated : .withoutAnimation)
deletingHandlers.didDelete?(itemsToDelete, transaction)
if self.tableView.allowsEmptySelection == false, self.tableView.selectedRowIndexes.isEmpty {
self.deletingHandlers.didDelete?(itemsToDelete, transaction)
if !self.tableView.allowsEmptySelection, self.tableView.selectedRowIndexes.isEmpty {
var selectionRow: Int? = nil
if let item = selectionItem, let row = self.row(for: item) {
selectionRow = row
Expand Down

0 comments on commit f0a62b1

Please sign in to comment.