Post

Replies

Boosts

Views

Activity

Text is cut off when selected on macOS
When I select text in a text field or regular text view in SwiftUI the text shifts and is cut off and I can only see half of the value on screen. Example of a text field using .textFieldStyle(.plain). Example of text view using .textSelection(.enabled). The text color also changes from white to black when in dark mode. I'm not sure what I'm doing wrong here for these views.
0
0
496
Jan ’23
NSDiffableDataSourceSectionSnapshot with more than 80 sections causes UI hangs
I am trying to create this UI using a diffable data source. I have everything working, however, we experience a severe UI hang, between 2200-3000ms, if there are more than 80 sections. It doesn't matter how many items are in the sections, just that there are over 80. Here is the setup for the snapshots. var snapshot = Snapshot() snapshot.appendSections(sections.map(\.branch)) apply(snapshot, animatingDifferences: animatingDifferences) sections.forEach { section in var sectionSnapshot = SectionSnapshot() if let currentBuild = section.builds.first.map({ SectionItem.currentBuild($0) }) { sectionSnapshot.append([currentBuild]) } if section.builds.count > 1 { let additionalBuildsHeader = SectionItem.additionalBuildsHeader(forSection: section.branch) sectionSnapshot.append([additionalBuildsHeader]) let additionalBuilds = section.builds .dropFirst() .map({ SectionItem.additionalBuild($0) }) sectionSnapshot.append(additionalBuilds, to: additionalBuildsHeader) if expandedSections.contains(additionalBuildsHeader) { sectionSnapshot.expand([additionalBuildsHeader]) } } apply(sectionSnapshot, to: section.branch, animatingDifferences: animatingDifferences) } I tried to do this with a single data source snapshot, instead of using the section snapshots and then the UI does not experience any hangs. While this works, we don't get the nice collapsible sections and all builds are displayed at the same level. Here is the code for that setup. var snapShot = Snapshot() snapShot.appendSections(sections.map(\.branch)) sections.forEach { section in     if let currentBuild = section.builds.first.map({ SectionItem.currentBuild($0) }) {         snapShot.appendItems([currentBuild], toSection: section.branch)     } if section.builds.count > 1 {         let additionalBuilds = section.builds                 .dropFirst()                 .map({ SectionItem.additionalBuild($0) })         snapShot.appendItems(additionalBuilds, toSection: section.branch)     } } apply(snapShot, animatingDifferences: animatingDifferences) Am I doing something wrong here with this setup in using the section snapshots? It seems like the hangs might be due to a layout pass being triggered on each apply, but I don't know any other way to build the section snapshots.
2
0
628
Jan ’23