WCAG 2.2 AA accessibility audit of widgets
epic-bufdir-report-period-selection-foundation-task-009 — Perform a structured WCAG 2.2 AA accessibility audit on PeriodPresetList and CustomDateRangePicker. Verify contrast ratios for all text and interactive elements, confirm touch targets meet 44x44dp minimum, validate that all controls have semantic labels readable by TalkBack and VoiceOver, test keyboard focus order, and confirm error messages are announced by live regions. Document any failures and apply fixes.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 3 - 413 tasks
Can start after Tier 2 completes
Implementation Notes
Start with automated SemanticsController assertions in a widget test to catch missing labels early without a device. Then follow up with manual screen reader testing on emulators to catch announcement ordering issues that automated tests miss. For live region error announcements, wrap the error Text in Semantics(liveRegion: true, child: ...) — Flutter will emit the appropriate platform accessibility event. For contrast: use design tokens from the shared token file rather than hardcoded hex values; if a token fails contrast, update the token, not an inline colour.
Ensure CustomDateRangePicker uses ExcludeSemantics on purely decorative icons (calendar icon, separator dash) to avoid screen reader noise. For the accessibility_preferences.font_scale_factor, verify widgets do not overflow at scale factors up to 2.0.
Testing Requirements
Use flutter_test's SemanticsController to assert semantic labels and live regions programmatically. Run manual TalkBack (Android emulator) and VoiceOver (iOS simulator) smoke tests for focus order and announcement quality. Use a contrast analysis tool (e.g. browser DevTools colour picker or Flutter's Accessibility Scanner) to verify contrast ratios against the design token colour values in styles.
Document results per WCAG success criterion: 1.4.3 (contrast minimum), 1.4.11 (non-text contrast), 2.4.3 (focus order), 2.5.5 (target size), 4.1.3 (status messages).
Supabase RLS policies for period preset configuration may be missing or incorrectly scoped, causing one organisation's presets to leak to another or write operations to fail silently.
Mitigation & Contingency
Mitigation: Define and review RLS policies for the bufdir_period_presets table in the migration file before any repository code is written. Include an integration test that verifies cross-organisation isolation using two distinct org credentials.
Contingency: If RLS is misconfigured in production, immediately disable the period preset fetch endpoint and fall back to hardcoded global presets until the policy is corrected and redeployed.
The activities table may lack a composite index on (organisation_id, activity_date), causing the range count query in BufdirAggregationRepository to perform a full table scan and exceed acceptable response time for large organisations.
Mitigation & Contingency
Mitigation: Add a migration that creates a composite index on (organisation_id, activity_date) as part of this epic. Benchmark the count query against a representative dataset (10 000+ rows) before marking the epic complete.
Contingency: If query latency is unacceptable after indexing, move the count query to a Supabase RPC function that leverages a materialised view or partial index, accepting a slight staleness window.
Flutter's native date picker widgets have known accessibility gaps (missing semantic labels, non-standard focus traversal) that may prevent WCAG 2.2 AA compliance out of the box, requiring a custom implementation.
Mitigation & Contingency
Mitigation: Evaluate third-party accessible date picker packages (e.g., table_calendar with custom semantics) against WCAG 2.2 AA criteria before beginning implementation. Document the chosen approach in the epic kick-off.
Contingency: If no package meets accessibility requirements, implement a simple text-field-based date entry with explicit semantic labels and format hints as an accessible fallback, deferring a fully visual calendar to a later iteration.