Skip to content

Commit 8a3731d

Browse files
committed
Add contentShape to button and view hit areas
Ensure correct hit-testing for shaped UI elements by adding .contentShape to capsule and rounded-rectangle controls. Adds contentShape(Capsule()) to capsule secondary button variants and contentShape(RoundedRectangle(...)) to the primary action button and SwiftNEW view background so the full visible shapes (including transparent/glass areas) receive interactions reliably.
1 parent 9ab98b1 commit 8a3731d

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

Sources/SwiftNEW/Views/Components/ButtonComponents.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ extension SwiftNEW {
7474
capsuleSecondaryButtonLabel(label: label)
7575
.padding(.horizontal, 14)
7676
.padding(.vertical, 8)
77+
.contentShape(Capsule())
7778
}
7879
.buttonStyle(.plain)
7980
.glassEffect(.clear.interactive(), in: .capsule)
@@ -104,6 +105,7 @@ extension SwiftNEW {
104105
) -> some View {
105106
Button(action: action) {
106107
capsuleSecondaryButtonLabel(label: label)
108+
.contentShape(Capsule())
107109
}
108110
#if !os(visionOS)
109111
.buttonStyle(.bordered)
@@ -140,6 +142,7 @@ extension SwiftNEW {
140142
#elseif os(tvOS)
141143
.tint(.white)
142144
#endif
145+
.contentShape(RoundedRectangle(cornerRadius: primaryActionButtonCornerRadius, style: .continuous))
143146
}
144147
.swiftNEWGlass(radius: primaryActionButtonCornerRadius, color: color.opacity(0.1))
145148
}

Sources/SwiftNEW/Views/SwiftNEW+View.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ extension SwiftNEW {
145145
.background(size != "mini" && size != "invisible" ? color : Color.clear)
146146
.cornerRadius(15)
147147
#endif
148+
.contentShape(RoundedRectangle(cornerRadius: 15, style: .continuous))
148149
}
149150
.opacity(size == "invisible" ? 0 : 1)
150151
.modifier(ConditionalGlassModifier(isEnabled: glass, shadowColor: color))

0 commit comments

Comments
 (0)