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: Fixes focus going to start of document when Note History is open #11769

Merged
merged 4 commits into from
Feb 7, 2025

Conversation

pedr
Copy link
Collaborator

@pedr pedr commented Feb 3, 2025

Related to #10795

Summary

Previously when opening the Note History the focus of the page would go back to the start of the document. Here I'm using the focus utility to set it programmatically to the content of the Note History screen.

WCAG

Guideline 2.4.3. Focus Order

Testing

  1. Open Note History
  2. Press tab/or use arrow
  3. Focus should be visible on the content of the note history instead of the start of the document.

@@ -92,6 +93,7 @@ const NoteRevisionViewerComponent: React.FC<Props> = ({ themeId, noteId, onBack,

setRevisions(revisions);
setCurrentRevId(revisions.length ? revisions[revisions.length - 1].id : '');
focus('NoteRevisionViewer::viewer_domReady', viewerRef.current);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you for working on this! To prevent the autofocus from being removed in the future, consider adding a comment explaining why this autofocus is necessary.

(Optional): It may make more sense for focus to initially jump to the revisions dropdown menu.

@@ -180,6 +182,12 @@ const NoteRevisionViewerComponent: React.FC<Props> = ({ themeId, noteId, onBack,

const viewer = <NoteTextViewer themeId={themeId} viewerStyle={{ display: 'flex', flex: 1, borderLeft: 'none' }} ref={viewerRef} onDomReady={viewer_domReady} onIpcMessage={webview_ipcMessage} />;

React.useEffect(() => {
Copy link
Owner

Choose a reason for hiding this comment

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

No React.useEffect please - just useEffect

@@ -180,6 +182,12 @@ const NoteRevisionViewerComponent: React.FC<Props> = ({ themeId, noteId, onBack,

const viewer = <NoteTextViewer themeId={themeId} viewerStyle={{ display: 'flex', flex: 1, borderLeft: 'none' }} ref={viewerRef} onDomReady={viewer_domReady} onIpcMessage={webview_ipcMessage} />;

React.useEffect(() => {
// We need to force focus here because the otherwise the focus is lost and goes back
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
// We need to force focus here because the otherwise the focus is lost and goes back
// We need to force focus here because otherwise the focus is lost and goes back

@pedr pedr requested a review from laurent22 February 7, 2025 20:39
@laurent22 laurent22 merged commit f5d168b into laurent22:dev Feb 7, 2025
7 checks passed
@pedr pedr deleted the note-revision-loses-focus branch February 7, 2025 20:51
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants