rechsteiner / Parchment

A paging view with a highly customizable menu ✨
MIT License
3.36k stars 418 forks source link

Accessibility - VoiceOver #407

Open vgillestad opened 4 years ago

vgillestad commented 4 years ago

I'll use the cities example on the front page as reference.

If you enable VoiceOver on your phone you can select one of the cities in the menu by tapping it. By "flicking" left or right you can navigate city-by-city in the menu (typical UICollectionView behaviour). (When you have found your city of choice you double tap and that city will get selected in the menu and the page scrolls.)

The problem is that the "flicking" to go city-by-city works maybe for two or three items. Then there seems to be some unexpected behaviour from Parchment which makes the VoiceOver not going to next city, but instead jump to the next container on the entire page (typically the first element on the current page).

Any help would be much appreciated! Please tell me if you need some more details.

rechsteiner commented 4 years ago

Hi @vgillestad! Thanks for the report. I'm not 100% if this is the issue, but I'm guessing it's related to the fact that we're reloading the data source while scrolling in the collection view when there's a lot of items. I'll look into getting this fixed.

rechsteiner commented 4 years ago

I've been looking a bit more into this lately, but I haven't been able to fix it yet. The reason the jump is happening is because of reloading data. When the user reaches the edge of the collection view, we append the next batch of items and call reloadData. This seems to cause VoiceOver to move the focused cell. It seems to work if I manually set the focus after we call reload data like this:

UIAccessibility.post(notification: .layoutChanged, argument: cell)

But I'm struggling to know which cell to select as I don't know which cell was focuses before the collection view was reloaded. Please let me know if you have any ideas on how this could be solved!