Skip to content

Commit

Permalink
Merge pull request #17761 from wordpress-mobile/issue/17760-prevent-v…
Browse files Browse the repository at this point in the history
…oiceover-calendar-scrollback

Calendar Accessibility: Prevent VoiceOver Calendar Scrollback
  • Loading branch information
joshheald authored Jan 14, 2022
2 parents 9111284 + 78675a3 commit 87fa323
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
19.1
-----
* [*] Signup: Fixed bug where username selection screen could be pushed twice. [#17624]
* [**] Accessibility: VoiceOver improvements on Activity Log and Schedule Post calendars [#17756]
* [**] Accessibility: VoiceOver improvements on Activity Log and Schedule Post calendars [#17756, #17761]

19.0
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,33 @@ class CalendarCollectionView: WPJTACMonthView {
calendarDataSource = calDataSource
calendarDelegate = calDataSource
}

/// VoiceOver scrollback workaround
/// When using VoiceOver, moving focus from the surrounding elements (usually the next month button) to the calendar DateCells, a
/// scrollback to 0 was triggered by the system. This appears to be expected (though irritating) behaviour with a paging UICollectionView.
/// The impact of this scrollback for the month view calendar (as used to schedule a post) is that the calendar jumps to 1951-01-01, with
/// the only way to navigate forwards being to tap the "next month" button repeatedly.
/// Ignoring these scrolls back to 0 when VoiceOver is in use prevents this issue, while not impacting other use of the calendar.
/// Similar behaviour sometimes occurs with the non-paging year view calendar (as used for activity log filtering) which is harder to reproduce,
/// but also remedied by this change.
override func setContentOffset(_ contentOffset: CGPoint, animated: Bool) {
if shouldPreventAccessibilityFocusScrollback(for: contentOffset) {
return
}
super.setContentOffset(contentOffset, animated: animated)
}

func shouldPreventAccessibilityFocusScrollback(for newContentOffset: CGPoint) -> Bool {
if UIAccessibility.isVoiceOverRunning {
switch style {
case .month:
return newContentOffset.x == 0 && contentOffset.x > 0
case .year:
return newContentOffset.y == 0 && contentOffset.y > 0
}
}
return false
}
}

class CalendarDataSource: JTACMonthViewDataSource {
Expand Down

0 comments on commit 87fa323

Please sign in to comment.