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 } }