From 32812bd5575fefcb5f71626c5138e80257dd00a8 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 15 Jul 2026 08:51:03 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Palette:=20[Make=20Script=20Exam?= =?UTF-8?q?ples=20Gallery=20Accessible]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 💡 What: Replaced `.onTapGesture` with a `Button` wrapper for ExampleCards in `ScriptExamplesGalleryView.swift`. 🎯 Why: Using `.onTapGesture` prevents keyboard users (tabbing, spacebar to activate) from interacting with the UI. Wrapping it in a Button restores this standard accessibility behavior. ♿ Accessibility: Ensures full keyboard interaction and screen reader support by attaching `.help()` and `.accessibilityLabel()` with dynamic names. Co-authored-by: NSEvent <44446865+NSEvent@users.noreply.github.com> --- .Jules/palette.md | 3 +++ .../Views/Scripts/ScriptExamplesGalleryView.swift | 14 +++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.Jules/palette.md b/.Jules/palette.md index 58909748..6d536305 100644 --- a/.Jules/palette.md +++ b/.Jules/palette.md @@ -29,3 +29,6 @@ ## 2024-07-12 - [Dynamic Accessibility Labels for List Item Actions] **Learning:** Icon-only buttons (like Edit/Delete) inside lists pose a major accessibility challenge for VoiceOver users when identical labels ("Edit") are repeated without context, making it impossible to know which row is being acted on. **Action:** Always interpolate the dynamic item context (e.g., `item.name`) into both `.help()` tooltips and `.accessibilityLabel()` modifiers in repeated SwiftUI lists. Include fallback text for empty states (e.g., `"Unnamed Item"`). +## 2024-05-24 - [Accessible List Items] +**Learning:** Using `.onTapGesture` on list items or cards in SwiftUI breaks keyboard interactivity and drops standard accessibility traits. It prevents users from tabbing to the item or pressing Space/Enter to activate it. +**Action:** When making elements interactive, wrap them in a `Button` with `.buttonStyle(.plain)` instead of using `.onTapGesture`. This natively supports keyboard navigation and correctly propagates `.help()` and `.accessibilityLabel()` to screen readers. diff --git a/XboxControllerMapper/XboxControllerMapper/Views/Scripts/ScriptExamplesGalleryView.swift b/XboxControllerMapper/XboxControllerMapper/Views/Scripts/ScriptExamplesGalleryView.swift index d9c2a535..aaf73d3e 100644 --- a/XboxControllerMapper/XboxControllerMapper/Views/Scripts/ScriptExamplesGalleryView.swift +++ b/XboxControllerMapper/XboxControllerMapper/Views/Scripts/ScriptExamplesGalleryView.swift @@ -26,11 +26,15 @@ struct ScriptExamplesGalleryView: View { ScrollView { LazyVGrid(columns: columns, spacing: 12) { ForEach(ScriptExamplesData.all) { example in - ExampleCard(example: example) - .onTapGesture { - onSelect(example) - dismiss() - } + Button(action: { + onSelect(example) + dismiss() + }) { + ExampleCard(example: example) + } + .buttonStyle(.plain) + .help("Use \(example.name) example") + .accessibilityLabel("Use \(example.name) example") } } .padding()