diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 97fcd08f3f00..06bc4457ae37 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -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 ----- diff --git a/WordPress/Classes/ViewRelated/Post/Scheduling/CalendarCollectionView.swift b/WordPress/Classes/ViewRelated/Post/Scheduling/CalendarCollectionView.swift index dc349815f3e6..5987e81ed8e6 100644 --- a/WordPress/Classes/ViewRelated/Post/Scheduling/CalendarCollectionView.swift +++ b/WordPress/Classes/ViewRelated/Post/Scheduling/CalendarCollectionView.swift @@ -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 {