Fix: Accessibility with overlaying popups #136
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes 2 issues -
Views list constantly growing
AndroidMopups
is essentially a singleton/ static class. So currently theViews
list (used to keep track of pages accessibility was applied to), is constantly growing every time a popup is opened. I thought each popup would have its own class/ list. And when the popup was removed the class/ list would go with it, but that is not the case.The current implementation of accessibility only works for 1 popup open at any one time. This is because whenever a popup is removed it resets the accessibility handling on all the pages in the views list.
Underlying popups are never treated for accessibility like pages. Meaning if a popup is open on top of another popup, then screenreader/ keyboard users will be able to interact with both.
Fix
The fix applied fixes both issues. Rather than storing a single list of views, it now creates a dictionary where the Key is the popup and the value is a list of views it altered when it opened. Also added a check to add any underlying popups to the view list to be treated for accessibility.
When the popup is closed/removed it only loops the views associated with its key and then removes itself from the dictionary.
To avoid duplicate page handling, it now checks to see if accessibility has already been handled for the page, if it has then it's ignored.