Skip to content
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

Bk/another accessibility refactor #297

Merged
merged 3 commits into from
Jan 29, 2024

Conversation

bryankeller
Copy link
Contributor

Details

This PR makes further accessibility improvements. The main thing here is that we no longer post .layoutChanged or .screenChanged notifications to force focus, and instead rely on UIScrollView to handle maintaining element focus for us (which works well, as long as views aren't reused!).

Speaking of that, this disables view recycling when voice over is active. This greatly simplifies things, and removes the need to constantly try to regain control over the focus. I should have thought of this sooner 🫠 We still have flat memory usage since off-screen views are simply deallocated. We pay a small CPU performance price, but Voice Over users won't be scrolling super fast anyways, so the tradeoff seems good. The overall UX for Voice Over users is significantly improved since focus never temporarily jumps around.

Related Issue

N/A

Motivation and Context

Improve VO UX

How Has This Been Tested

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

@bryankeller bryankeller added the bug Something isn't working label Jan 26, 2024
@bryankeller bryankeller force-pushed the bk/another-accessibility-refactor branch from 5fdc746 to a63c3a1 Compare January 26, 2024 03:20
@@ -25,6 +25,7 @@ final class ItemViewReuseManager {

func viewsForVisibleItems(
_ visibleItems: Set<VisibleItem>,
recycleOldViews: Bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

Something more descriptive?

Suggested change
recycleOldViews: Bool,
recycleOffscreenViews: Bool,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice, I like that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They might not be offscreen, so going with recycleUnusedViews (imagine we just switch from using DayViewA to DayViewB for a visible day, it's not really offscreen in terms of being within the visible bounds of the scroll view)

@@ -526,6 +520,14 @@ public final class CalendarView: UIView {
private lazy var scrollViewDelegate = ScrollViewDelegate(calendarView: self)
private lazy var gestureRecognizerDelegate = GestureRecognizerDelegate(calendarView: self)

private var hasHadInitialItemViewFocus = false {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
private var hasHadInitialItemViewFocus = false {
private var initialItemViewWasFocused = false {

Copy link
Contributor

@brynbodayle brynbodayle left a comment

Choose a reason for hiding this comment

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

Good trade off!

@bryankeller bryankeller force-pushed the bk/another-accessibility-refactor branch 13 times, most recently from 655641b to 7fbe53d Compare January 27, 2024 02:14
@bryankeller bryankeller force-pushed the bk/another-accessibility-refactor branch from 7fbe53d to 1c5e9ac Compare January 29, 2024 20:26
@bryankeller bryankeller merged commit 6d6d11a into master Jan 29, 2024
2 checks passed
@bryankeller bryankeller deleted the bk/another-accessibility-refactor branch January 29, 2024 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants