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

Mobile: Accessibility: Improve dialog accessibility #11395

Conversation

personalizedrefrigerator
Copy link
Collaborator

@personalizedrefrigerator personalizedrefrigerator commented Nov 15, 2024

Summary

This pull request improves the accessibility of certain dialog components by replacing react-native-dialogbox with a custom dialog component.

react-native-dialogbox has the following accessibility issues:

  • Focus does not move to the dialog and is not adjacent to the dialog when it opens (WCAG 2.2/F85).
  • When the dialog is dismissed, focus transitions to the document (and not the button that opened the dialog) (WCAG 2.2/F85).
  • Items behind the dialog can be focused while the dialog is still open (see WCAG 2.2/SC 2.4.11).
  • On small screens, in landscape mode, or on devices with large font sizes, it isn't possible to access all menu items (some are offscreen) (fails WCAG 2.2/SC 1.4.10).
  • (Not fixed by this PR): Checked/unchecked items aren't read as such by TalkBack in the "sort by" option.

This pull request fixes most of the above issues.

Related to #10795.

Implementation details

react-native-dialogbox is replaced by extending the existing custom dialog logic used for the web client. In particular,

  1. Due to a styling issue, custom dialogs only worked on web. This pull request fixes that issue.
  2. The custom dialogs are implemented using a React Native Modal, which captures focus when the dialog is opened and restores focus when the dialog is closed.
    • Previously, when opening the "sort notes by" or certain info dialogs, accessibility focus would not move to the dialog.
  3. Wraps custom dialogs in a ScrollView to allow all items to be accessed on small screens.

Screenshots

Web

Sort dialog: Larger screen/light mode

screenshot: Shows the dialog before and after. Before, the backdrop fading is darker. After, it's slightly lighter

Sort dialog: Small screen/light mode

The following before/after comparison shows the "sort notes by" dialog on web at 320x256 screen resolution (as required by WCAG 2.2/SC 1.4.10):
image

Before, some items were clipped offscreen and could not be scrolled to. With this change, it's possible to scroll the dialog vertically to access the items.

Sort dialog: Small screen/dark mode

As above, this screenshot is a before/after comparison, but in dark mode. The updated dialog uses Joplin's theme colors, while the original does not:

image

Alert dialog

On web, alert dialogs and menu dialogs now share code. The alert dialog style has changed. In particular, it uses theme.backgroundColor1 rather than the default color for elevated surfaces:

image

This more closely matches the style of other dialogs (e.g. the plugin info dialog).

This does, however, make the dialog less visible in dark mode:
image

Screen recording

iOS

The attached screen recording demonstrates:

  1. Opening the "sort notes by" dialog with VoiceOver.
  2. Observing that focus moves to the dialog title.
  3. Selecting an option and observing that focus is not properly restored (upstream React Native issue).
  4. Opening a note and attaching a photo using the "attach" dialog.
  5. Disabling VoiceOver.
    • On the Simulator, VoiceOver doesn't seem to work with the "pick photo" dialog.
  6. Choosing a photo.
  7. Observing that the "resize" dialog is visible.
  8. Choosing an option from the dialog.
  9. Showing the notes list.
  10. Opening the "sort notes by" dialog.
  11. Dismissing the "sort notes by" dialog by tapping on its background.
  12. Switching to landscape mode.
  13. Scrolling the "sort notes by" dialog.
out.webm

Android

Portrait:
The attached video demonstrates:

  1. Disabling encryption from the encryption config screen.
    • A confirmation dialog is shown and "no" is selected.
    • The dialog is re-opened and "yes" is selected.
  2. Opening the Dropbox sync screen, entering an invalid key, clicking "Cancel" in the dialog that's shown.
  3. Opening the "sort by" dialog.
  4. Closing the dialog by clicking on its background.
  5. Opening a note and opening the "attach" menu.
  6. Closing the menu and re-opening it.
  7. Selecting "Attach file", then closing the file chooser with the back button.
  8. Re-opening the attach menu and closing it with the device back button.
  9. Opening the "draw picture" dialog.
  10. Drawing something.
  11. Closing it and clicking "discard changes" in the "unsaved changes" dialog.
  12. Showing the notes list and enabling TalkBack.
  13. Opening the "sort by" dialog with TalkBack.
  14. Navigating through the items in the dialog.
  15. Selecting an option.
  16. At this point, the accessibility focus moves back to the "sort by" button (the button that opened the dialog), as expected.
  17. Re-opening the "sort by" dialog.
  18. Moving focus to the back button.
  19. Clicking the back button.
  20. This closes the "sort by" dialog.
  21. Re-opening the "sort by" dialog.
  22. Changing the sort order.
android-1.webm

Landscape mode:
The attached recording demonstrates:

  1. Scrolling the "sort by" dialog vertically in landscape mode.
  2. Opening settings.
  3. Switching to dark mode.
  4. Opening the sort by dialog.
  5. Scrolling it and selecting an option.
untitled.webm

@personalizedrefrigerator personalizedrefrigerator added mobile All mobile platforms accessibility Related to accessibility labels Nov 15, 2024
}]);
});
},
prompt: (title: string, message: string, buttons: PromptButton[] = defaultButtons, options?: PromptOptions) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note: This function was originally in DialogManager.tsx.

Comment on lines +38 to +39
// Note: Alert.alert provides a more native style on iOS.
Alert.alert(title, message, buttons, options);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For now, this continues to use the React Native Alert.alert when .prompt is called on Android and iOS. If desired, this could be adjusted to always use the custom alert dialogs.

@personalizedrefrigerator personalizedrefrigerator changed the title Mobile: Accessibility: Improve dialog focus accessibility Mobile: Accessibility: Improve dialog accessibility Nov 16, 2024
@laurent22
Copy link
Owner

That looks good, thank you for improving this. The dialogs overall look better and I don't think it's too much of an issue the message box background on dark theme

@laurent22 laurent22 merged commit 84eab77 into laurent22:dev Nov 16, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility Related to accessibility mobile All mobile platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants