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

Desktop: Accessibility: Allow toggling between tab navigation and indentation #11717

Open
wants to merge 11 commits into
base: dev
Choose a base branch
from

Conversation

personalizedrefrigerator
Copy link
Collaborator

@personalizedrefrigerator personalizedrefrigerator commented Jan 23, 2025

Summary

Note

Before this pull request, esc then tab could be used to escape focus traps (the Markdown & Rich Text editors). However, this shortcut fails SC 2.1.1 because, at least in the Markdown editor, tab must currently be pressed quickly after pressing escape, thus requiring "specific timings for individual keystrokes".

ctrl-m is used as the default "toggle tab indentation" shortcut to match VSCode and the shortcut in the default CodeMirror configuration.

This pull request's goal is to help Joplin meet WCAG 2.2 SC 2.1.2 without relying on a specific timing of keyboard events (SC 2.1.1). It applies to the CodeMirror 6 Markdown editor, the Rich Text Editor, and the Rich Text Editor's code block editor.

Related to #10795.

Screenshots

Menu item

screenshot: Menu item checked, "tab moves focus" ctrl+m

Status indicator

The status indicator for this feature is based on VSCode's UI for the same feature.

  • In Joplin:
    screenshot: Tab moves focus shown near bottom right of the editor
    Notice the "tab moves focus" button near the bottom right of the editor. When tab-to-indent is enabled (the default), "tab moves focus" is hidden.
  • In VSCode (for comparison):
    Screenshot: "Tab Moves Focus" shown in the statusbar at the bottom of the screen
    Notice that "Tab Moves Focus" is included in the statusbar at the bottom of the screen.

Testing

Automated tests: This pull request includes an automated test that verifies that tab indentation can be toggled (and that this toggles the status indicator) using the menu item from the Rich Text Editor. A similar test has been added for the "edit code block" screen from the RTE.

Manual testing (Fedora 41):

  1. Focus the Markdown editor.
  2. Press tab.
  3. Verify that indentation/a tab character has been added.
  4. Press ctrl-m.
  5. Press tab and verify that focus has left the Markdown editor.
  6. Click the "tab moves focus" status indicator.
  7. Focus the Markdown editor.
  8. Press tab.
  9. Verify that a tab character has been inserted.

@personalizedrefrigerator personalizedrefrigerator added desktop All desktop platforms accessibility Related to accessibility labels Jan 23, 2025

export const declaration: CommandDeclaration = {
name: 'toggleTabKeyNavigation',
label: () => _('Toggle editor tab key navigation'),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Currently, this label is only shown in keyboard shortcut settings. To avoid having to localize it, an alternative might be to get the label from the setting (as is done in MenuBar.tsx). However, this would result in a label of Tab moves focus, which doesn't describe the command's toggling action.

Comment on lines +25 to +27
// Even if not visible, [label] should reflect the current state
// of the indicator.
label: string;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To better support screen readers and keyboard-only users:

  • The status indicator announces changes to the setting with aria-live=polite.
  • Changing the keyboard focus mode (e.g. by pressing enter) when the status indicator has focus keeps the status indicator visible but changes its label to "Tab indents".

const tagList = props.selectedNoteTags.length ? <TagList items={props.selectedNoteTags} /> : null;

return (
<div style={{ paddingLeft: 8, display: 'flex', flexDirection: 'row', alignItems: 'center' }}>{tagList}{instructions}</div>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was moved from NoteEditor.tsx.

@personalizedrefrigerator personalizedrefrigerator changed the title Desktop: Accessibility: Allow toggling between tab indentation/navigation Desktop: Accessibility: Allow toggling between tab navigation and indentation Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility Related to accessibility desktop All desktop platforms editor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant