Skip to content

Commit 0854af3

Browse files
weiranclaude
andcommitted
Fix comments pill showing disabled appearance in comments view
The comments pill was appearing disabled in the comments view because it had no action handler. Updated the pill rendering logic to show static content (instead of a disabled button) when enabled but with no action, preventing the disabled styling from being applied. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent fd9cf06 commit 0854af3

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

DesignSystem/Sources/DesignSystem/Components/PostDisplayView.swift

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ public struct PostDisplayView: View {
189189
accessibilityLabel: "\(post.commentsCount) comments",
190190
isHighlighted: false,
191191
isLoading: false,
192+
isEnabled: true,
192193
numericValue: post.commentsCount,
193194
action: onCommentsTap
194195
)
@@ -370,16 +371,27 @@ public struct PostDisplayView: View {
370371
}
371372
}
372373

373-
return Button(action: action ?? {}) {
374+
let shouldDisable = !isEnabled || isLoading
375+
let shouldBeInteractive = isEnabled && !isLoading && action != nil
376+
377+
// If enabled but no action, render as static view to avoid disabled styling
378+
if isEnabled && !isLoading && action == nil {
374379
content
380+
.accessibilityElement(children: .combine)
381+
.accessibilityLabel(accessibilityLabel)
382+
.accessibilityHint(accessibilityHint ?? "")
383+
} else {
384+
Button(action: action ?? {}) {
385+
content
386+
}
387+
.buttonStyle(.plain)
388+
.disabled(!shouldBeInteractive)
389+
.allowsHitTesting(shouldBeInteractive)
390+
.opacity(shouldDisable ? 0.6 : 1.0)
391+
.accessibilityElement(children: .combine)
392+
.accessibilityLabel(accessibilityLabel)
393+
.accessibilityHint(accessibilityHint ?? "")
375394
}
376-
.buttonStyle(.plain)
377-
.disabled(!isEnabled || isLoading || action == nil)
378-
.allowsHitTesting(isEnabled && !isLoading && action != nil)
379-
.opacity(isEnabled && !isLoading ? 1.0 : 0.6)
380-
.accessibilityElement(children: .combine)
381-
.accessibilityLabel(accessibilityLabel)
382-
.accessibilityHint(accessibilityHint ?? "")
383395
}
384396
}
385397

0 commit comments

Comments
 (0)