-
Notifications
You must be signed in to change notification settings - Fork 108
[MBL-19507][All] Fix first back press not working in Calendar screen #3426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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]>
There was a problem hiding this 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
conditionalmodifier pattern - Proper imports added
- Minimal, focused change
Recommendations
- Fix the state bug: Update
isScreenReaderEnabled()in Utils.kt to properly observe accessibility state changes, not just capture the initial value - Add tests: Update CalendarScreenTest.kt to verify the focusable modifier is applied correctly based on screen reader state
- 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!
...ils/src/main/java/com/instructure/pandautils/features/calendar/composables/CalendarScreen.kt
Show resolved
Hide resolved
🧪 Unit Test Results✅ 📱 Parent App
✅ 📱 Student App
✅ 📱 Teacher App
✅ 🌅 Horizon
✅ 📦 Submodules
📊 Summary
Last updated: Tue, 02 Dec 2025 10:41:40 GMT |
📊 Code Coverage Reportℹ️ Student
ℹ️ Teacher
ℹ️ Pandautils
|
hermannakos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QA + 1
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 viafocusRequester.tryRequestFocus(). In Android's standard behavior, when a view has focus, the first back press clears the focus instead of propagating to the Activity'sonBackPressed().The Fix
Conditionally apply the
.focusable()modifier only when TalkBack (or other screen readers) is enabled using theisScreenReaderEnabled()utility and theconditionalmodifier.This ensures:
Test plan:
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
🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]