fix: region map tap selecting wrong region due to accessibility button overlay

Accessibility buttons split the map into equal-width thirds, intercepting
taps before the coordinate-based logic. Tapping the visual West region
could hit the Central button. Adding .allowsHitTesting(false) lets taps
pass through to MapReader's coordinate detection; VoiceOver still works.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Trey t
2026-02-13 09:12:00 -06:00
parent 9736773475
commit 67965cbac6
2 changed files with 121 additions and 2 deletions

View File

@@ -56,13 +56,15 @@ struct RegionMapSelector: View {
.mapStyle(.standard(elevation: .flat, pointsOfInterest: .excludingAll))
.onTapGesture { location in
if let coordinate = proxy.convert(location, from: .local) {
let tappedRegion = regionForCoordinate(coordinate)
let tappedRegion = Self.regionForCoordinate(coordinate)
onToggle(tappedRegion)
}
}
}
// Invisible button overlays for UI testing accessibility
// allowsHitTesting(false) lets taps pass through to the map's
// coordinate-based region detection; VoiceOver still reads these.
HStack(spacing: 0) {
Button { onToggle(.west) } label: { Color.clear }
.accessibilityIdentifier("wizard.regions.west")
@@ -98,6 +100,7 @@ struct RegionMapSelector: View {
.accessibilityAddTraits(selectedRegions.contains(.east) ? .isSelected : [])
.frame(maxWidth: .infinity)
}
.allowsHitTesting(false)
}
.frame(height: 160)
.clipShape(RoundedRectangle(cornerRadius: Theme.CornerRadius.medium))
@@ -128,7 +131,9 @@ struct RegionMapSelector: View {
/// West: States west of ~-102° (WA, OR, CA, NV, ID, UT, AZ, MT, WY, CO, NM)
/// Central: States between ~-102° and ~-89° (ND, SD, NE, KS, OK, TX, MN, IA, MO, AR, LA, WI, IL)
/// East: States east of ~-89°
private func regionForCoordinate(_ coordinate: CLLocationCoordinate2D) -> Region {
/// Maps a tap coordinate to a region based on the visual polygon boundaries.
/// Thresholds match the drawn polygon edges (not Region.classify which uses stadium locations).
static func regionForCoordinate(_ coordinate: CLLocationCoordinate2D) -> Region {
let longitude = coordinate.longitude
if longitude < -102 {
return .west