Skip to content

Conversation

@tamaskozmer
Copy link
Contributor

@tamaskozmer tamaskozmer commented Dec 2, 2025

Summary

Fixes an issue where the first back press on the Calendar screen didn't work, requiring users to press back twice to navigate away from the screen. This fix applies to all apps that use the Calendar feature (Student, Teacher, Parent).

Root Cause

The toolbar was marked as .focusable(), which caused it to receive keyboard focus when accessibility focus was triggered via focusRequester.tryRequestFocus(). In Android's standard behavior, when a view has focus, the first back press clears the focus instead of propagating to the Activity's onBackPressed().

The Fix

Conditionally apply the .focusable() modifier only when TalkBack (or other screen readers) is enabled using the isScreenReaderEnabled() utility and the conditional modifier.

This ensures:

  • ✅ TalkBack users still get proper accessibility focus announcements
  • ✅ Screen readers correctly announce "Calendar, heading" when the tab is selected
  • ✅ Regular users get immediate back navigation without the focus-clearing step
  • ✅ No degradation of accessibility features

Test plan:

  • Verify back press works on first press in Calendar screen (without TalkBack)
  • Enable TalkBack and verify accessibility focus still works when switching to Calendar tab
  • Verify screen reader announces the Calendar heading properly
  • Test on Student, Teacher, and Parent apps

refs: MBL-19507
affects: Student, Teacher, Parent
release note: Fixed an issue where the first back press on the Calendar screen didn't work

Checklist

  • Follow-up e2e test ticket created or not needed
  • Tested in dark mode
  • Tested in light mode
  • Test in landscape mode and/or tablet
  • A11y checked
  • Approve from product

🤖 Generated with Claude Code

Co-Authored-By: Claude [email protected]

The issue was caused by the toolbar being marked as focusable, which made it
receive keyboard focus when accessibility focus was triggered. In Android's
standard behavior, when a view has focus, the first back press clears the
focus rather than propagating to the Activity.

The fix conditionally applies the focusable modifier only when TalkBack (or
other screen readers) is enabled, ensuring:
- TalkBack users still get proper accessibility focus announcements
- Regular users get immediate back navigation without the focus-clearing step

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@tamaskozmer tamaskozmer changed the title [MBL-19507] Fix first back press not working in Calendar screen [MBL-19507][All] Fix first back press not working in Calendar screen Dec 2, 2025
Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Thanks for improving accessibility! The goal of conditionally applying focusable() only when a screen reader is enabled is good, but there are some issues that need attention.

Issues Found

  • State management bug in isScreenReaderEnabled() - The accessibility state is captured once at composition time and never updates dynamically (see inline comment on CalendarScreen.kt:147)
  • Missing test coverage - No tests verify the new conditional focusable behavior with screen readers enabled/disabled
  • Unclear behavior change - The PR description doesn't explain why focusable() should only apply when screen readers are enabled, which makes it difficult to understand the intent

Code Quality

Positive aspects:

  • Clean use of the conditional modifier pattern
  • Proper imports added
  • Minimal, focused change

Recommendations

  1. Fix the state bug: Update isScreenReaderEnabled() in Utils.kt to properly observe accessibility state changes, not just capture the initial value
  2. Add tests: Update CalendarScreenTest.kt to verify the focusable modifier is applied correctly based on screen reader state
  3. Document the intent: Add a comment explaining why this conditional is needed, or include the rationale in the PR description

Security & Performance

No security concerns identified. Performance impact is minimal.

Let me know if you'd like help implementing any of these fixes!

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

🧪 Unit Test Results

✅ 📱 Parent App

  • Tests: 310 total, 0 failed, 0 skipped
  • Duration: 34.529s
  • Success Rate: 100%

✅ 📱 Student App

  • Tests: 1226 total, 0 failed, 0 skipped
  • Duration: 0.000s
  • Success Rate: 100%

✅ 📱 Teacher App

  • Tests: 364 total, 0 failed, 0 skipped
  • Duration: 35.283s
  • Success Rate: 100%

✅ 🌅 Horizon

  • Tests: 449 total, 0 failed, 0 skipped
  • Duration: 32.359s
  • Success Rate: 100%

✅ 📦 Submodules

  • Tests: 2418 total, 0 failed, 0 skipped
  • Duration: 44.875s
  • Success Rate: 100%

📊 Summary

  • Total Tests: 4767
  • Failed: 0
  • Skipped: 0
  • Status: ✅ All tests passed!

Last updated: Tue, 02 Dec 2025 10:41:40 GMT

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

📊 Code Coverage Report

ℹ️ Student

  • PR Coverage: 42.77%
  • Master Coverage: N/A

ℹ️ Teacher

  • PR Coverage: 25.45%
  • Master Coverage: N/A

ℹ️ Pandautils

  • PR Coverage: 22.56%
  • Master Coverage: N/A

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

Parent Install Page

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

Student Install Page

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

Teacher Install Page

Copy link
Collaborator

@hermannakos hermannakos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QA + 1

@tamaskozmer tamaskozmer merged commit c276d95 into master Dec 4, 2025
50 of 52 checks passed
@tamaskozmer tamaskozmer deleted the MBL-19507-fix-calendar-back-press branch December 4, 2025 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants