From e108283e965b49058dec89f4fc9cb296ab8323e7 Mon Sep 17 00:00:00 2001 From: systemBlue Date: Tue, 2 Jun 2026 18:57:30 -0400 Subject: [PATCH] feat: make tappable diff lines act as buttons for VoiceOver Diff lines that accept a review comment used an onTapGesture, which VoiceOver neither announces as actionable nor reliably activates. Commentable lines are now wrapped in a Button (.plain style, so they look identical), giving them the button trait, an "Add a comment on this line" hint, and proper activation. Non-commentable lines stay plain. Co-Authored-By: Claude Opus 4.8 (1M context) --- Forji/Forji/Views/DiffView.swift | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Forji/Forji/Views/DiffView.swift b/Forji/Forji/Views/DiffView.swift index b61a8a7..5aa607e 100644 --- a/Forji/Forji/Views/DiffView.swift +++ b/Forji/Forji/Views/DiffView.swift @@ -60,8 +60,10 @@ struct DiffView: View { } } + @ViewBuilder private func diffLineRow(line: DiffLine, filePath: String) -> some View { - HStack(spacing: 0) { + let isCommentable = onLineTap != nil && line.type != .header && line.diffPosition != nil + let row = HStack(spacing: 0) { HStack(spacing: 2) { Text(line.oldLineNumber.map { "\($0)" } ?? "") .font(.system(.caption2, design: .monospaced)) @@ -88,7 +90,7 @@ struct DiffView: View { Spacer(minLength: 0) - if onLineTap != nil, line.type != .header, line.diffPosition != nil { + if isCommentable { Image(systemName: "plus.bubble") .font(.caption2) .foregroundStyle(.tertiary) @@ -100,10 +102,18 @@ struct DiffView: View { .padding(.vertical, 1) .background(line.type.backgroundColor) .contentShape(Rectangle()) - .onTapGesture { - if line.type != .header, line.diffPosition != nil { + + // A tappable line is a Button so VoiceOver announces it and can activate it. + if isCommentable { + Button { onLineTap?(line, filePath) + } label: { + row } + .buttonStyle(.plain) + .accessibilityHint("Add a comment on this line") + } else { + row } }