Use placeholder text when timeline title label width is not greater than 0 (as in a feed with a title that just a combining mark). Fixes #5574.

This commit is contained in:
Brent Simmons committed 2026-12-04 09:41:11 -08:00
1 parent 235742960b
commit 03c6f8fe00
1 file changed
+12 -4
@@ -169,7 +169,8 @@ final class MainTimelineViewController: UIViewController, UndoableCommandRunner
private static let logger = Logger(subsystem: Logger.nnwSubsystem, category: "MainTimelineViewController")
/// Cells queued within this interval, such as for several thumbnail downloads that failed, are reloaded together.
private static let cellReloadDelay: TimeInterval = 0.1
/// A zero-size titleView or subtitleView crashes UINavigationBar layout, so empty labels get a space instead.
/// A zero-width titleView or subtitleView crashes UINavigationBar layout, so labels whose text measures zero width (empty, or only a combining mark) get a space instead.
/// <https://github.com/Ranchero-Software/NetNewsWire/issues/5574>
private static let navigationBarPlaceholderText = " "
// MARK: Constants
@@ -316,16 +317,23 @@ final class MainTimelineViewController: UIViewController, UndoableCommandRunner
func updateNavigationBarTitle(_ text: String) {
navigationItem.title = text
if let label = navigationItem.titleView as? UILabel {
label.text = text.isEmpty ? Self.navigationBarPlaceholderText : text
label.isUserInteractionEnabled = ((coordinator?.timelineFeed as? PseudoFeed) == nil)
label.sizeToFit()
setNavigationBarLabelText(label, text)
}
}
func updateNavigationBarSubtitle(_ text: String) {
if #available(iOS 26, *), let label = navigationItem.subtitleView as? UILabel {
label.text = text.isEmpty ? Self.navigationBarPlaceholderText : text
label.isUserInteractionEnabled = ((coordinator?.timelineFeed as? PseudoFeed) == nil)
setNavigationBarLabelText(label, text)
}
}
private func setNavigationBarLabelText(_ label: UILabel, _ text: String) {
label.text = text
label.sizeToFit()
if !(label.bounds.width > 0) {
label.text = Self.navigationBarPlaceholderText
label.sizeToFit()
}
}